Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
persistent
Commits
930088ad
Commit
930088ad
authored
Oct 28, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new_ghost doesn't clear object state, preserving __getnewargs__ values.
parent
ff64867c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
16 deletions
+18
-16
persistent/persistence.py
persistent/persistence.py
+17
-15
persistent/picklecache.py
persistent/picklecache.py
+1
-1
No files found.
persistent/persistence.py
View file @
930088ad
...
...
@@ -413,27 +413,29 @@ class Persistent(object):
_OSA
(
self
,
'_Persistent__flags'
,
0
)
self
.
_p_deactivate
()
def
_p_invalidate_deactivate_helper
(
self
):
def
_p_invalidate_deactivate_helper
(
self
,
clear
=
True
):
jar
=
_OGA
(
self
,
'_Persistent__jar'
)
if
jar
is
None
:
return
if
_OGA
(
self
,
'_Persistent__flags'
)
is
not
None
:
_OSA
(
self
,
'_Persistent__flags'
,
None
)
idict
=
getattr
(
self
,
'__dict__'
,
None
)
if
idict
is
not
None
:
idict
.
clear
()
type_
=
type
(
self
)
# ( for backward-compatibility reason we release __slots__ only if
# class does not override __new__ )
if
type_
.
__new__
is
Persistent
.
__new__
:
for
slotname
in
Persistent
.
_slotnames
(
self
,
_v_exclude
=
False
):
try
:
getattr
(
type_
,
slotname
).
__delete__
(
self
)
except
AttributeError
:
# AttributeError means slot variable was not initialized at all -
# - we can simply skip its deletion.
pass
if
clear
:
idict
=
_OGA
(
self
,
'__dict__'
,
None
)
if
idict
is
not
None
:
idict
.
clear
()
type_
=
type
(
self
)
# for backward-compatibility reason we release __slots__ only if
# class does not override __new__
if
type_
.
__new__
is
Persistent
.
__new__
:
for
slotname
in
Persistent
.
_slotnames
(
self
,
_v_exclude
=
False
):
try
:
getattr
(
type_
,
slotname
).
__delete__
(
self
)
except
AttributeError
:
# AttributeError means slot variable was not initialized at all -
# - we can simply skip its deletion.
pass
# Implementation detail: deactivating/invalidating
# updates the size of the cache (if we have one)
...
...
persistent/picklecache.py
View file @
930088ad
...
...
@@ -246,7 +246,7 @@ class PickleCache(object):
# careful to avoid broken _p_invalidate and _p_deactivate
# that don't call the super class. See ZODB's
# testConnection.doctest_proper_ghost_initialization_with_empty__p_deactivate
obj
.
_p_invalidate_deactivate_helper
()
obj
.
_p_invalidate_deactivate_helper
(
False
)
self
[
oid
]
=
obj
def
reify
(
self
,
to_reify
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment