Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
fe0205eb
Commit
fe0205eb
authored
Dec 18, 2009
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up trailing whitespace.
parent
dbedfb3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
23 deletions
+23
-23
src/ZODB/persistentclass.py
src/ZODB/persistentclass.py
+23
-23
No files found.
src/ZODB/persistentclass.py
View file @
fe0205eb
...
@@ -18,29 +18,29 @@ $Id$
...
@@ -18,29 +18,29 @@ $Id$
# Notes:
# Notes:
#
#
# Persistent classes are non-ghostable. This has some interesting
# Persistent classes are non-ghostable. This has some interesting
# ramifications:
# ramifications:
#
#
# - When an object is invalidated, it must reload it's state
# - When an object is invalidated, it must reload it's state
#
#
# - When an object is loaded from the database, it's state must be
# - When an object is loaded from the database, it's state must be
# loaded. Unfortunately, there isn't a clear signal when an object is
# loaded. Unfortunately, there isn't a clear signal when an object is
# loaded from the database. This should probably be fixed.
# loaded from the database. This should probably be fixed.
#
#
# In the mean time, we need to infer. This should be viewed as a
# In the mean time, we need to infer. This should be viewed as a
# short term hack.
# short term hack.
#
#
# Here's the strategy we'll use:
# Here's the strategy we'll use:
#
#
# - We'll have a need to be loaded flag that we'll set in
# - We'll have a need to be loaded flag that we'll set in
# __new__, through an extra argument.
# __new__, through an extra argument.
#
#
# - When setting _p_oid and _p_jar, if both are set and we need to be
# - When setting _p_oid and _p_jar, if both are set and we need to be
# loaded, then we'll load out state.
# loaded, then we'll load out state.
#
#
# - We'll use _p_changed is None to indicate that we're in this state.
# - We'll use _p_changed is None to indicate that we're in this state.
#
#
class
_p_DataDescr
(
object
):
class
_p_DataDescr
(
object
):
# Descr used as base for _p_ data. Data are stored in
# Descr used as base for _p_ data. Data are stored in
...
@@ -56,7 +56,7 @@ class _p_DataDescr(object):
...
@@ -56,7 +56,7 @@ class _p_DataDescr(object):
if
'__global_persistent_class_not_stored_in_DB__'
in
inst
.
__dict__
:
if
'__global_persistent_class_not_stored_in_DB__'
in
inst
.
__dict__
:
raise
AttributeError
(
self
.
__name__
)
raise
AttributeError
(
self
.
__name__
)
return
inst
.
_p_class_dict
.
get
(
self
.
__name__
)
return
inst
.
_p_class_dict
.
get
(
self
.
__name__
)
def
__set__
(
self
,
inst
,
v
):
def
__set__
(
self
,
inst
,
v
):
inst
.
_p_class_dict
[
self
.
__name__
]
=
v
inst
.
_p_class_dict
[
self
.
__name__
]
=
v
...
@@ -68,14 +68,14 @@ class _p_oid_or_jar_Descr(_p_DataDescr):
...
@@ -68,14 +68,14 @@ class _p_oid_or_jar_Descr(_p_DataDescr):
# state when set if both are set and and _p_changed is None
# state when set if both are set and and _p_changed is None
#
#
# See notes above
# See notes above
def
__set__
(
self
,
inst
,
v
):
def
__set__
(
self
,
inst
,
v
):
get
=
inst
.
_p_class_dict
.
get
get
=
inst
.
_p_class_dict
.
get
if
v
==
get
(
self
.
__name__
):
if
v
==
get
(
self
.
__name__
):
return
return
inst
.
_p_class_dict
[
self
.
__name__
]
=
v
inst
.
_p_class_dict
[
self
.
__name__
]
=
v
jar
=
get
(
'_p_jar'
)
jar
=
get
(
'_p_jar'
)
if
(
jar
is
not
None
if
(
jar
is
not
None
and
get
(
'_p_oid'
)
is
not
None
and
get
(
'_p_oid'
)
is
not
None
...
@@ -85,12 +85,12 @@ class _p_oid_or_jar_Descr(_p_DataDescr):
...
@@ -85,12 +85,12 @@ class _p_oid_or_jar_Descr(_p_DataDescr):
class
_p_ChangedDescr
(
object
):
class
_p_ChangedDescr
(
object
):
# descriptor to handle special weird emantics of _p_changed
# descriptor to handle special weird emantics of _p_changed
def
__get__
(
self
,
inst
,
cls
):
def
__get__
(
self
,
inst
,
cls
):
if
inst
is
None
:
if
inst
is
None
:
return
self
return
self
return
inst
.
_p_class_dict
[
'_p_changed'
]
return
inst
.
_p_class_dict
[
'_p_changed'
]
def
__set__
(
self
,
inst
,
v
):
def
__set__
(
self
,
inst
,
v
):
if
v
is
None
:
if
v
is
None
:
return
return
...
@@ -116,7 +116,7 @@ class _p_MethodDescr(object):
...
@@ -116,7 +116,7 @@ class _p_MethodDescr(object):
def
__delete__
(
self
,
inst
):
def
__delete__
(
self
,
inst
):
raise
AttributeError
(
self
.
__name__
)
raise
AttributeError
(
self
.
__name__
)
special_class_descrs
=
'__dict__'
,
'__weakref__'
special_class_descrs
=
'__dict__'
,
'__weakref__'
...
@@ -145,12 +145,12 @@ class PersistentMetaClass(type):
...
@@ -145,12 +145,12 @@ class PersistentMetaClass(type):
if
(
if
(
(
data_manager
is
not
None
)
(
data_manager
is
not
None
)
and
and
(
get
(
'_p_oid'
)
is
not
None
)
(
get
(
'_p_oid'
)
is
not
None
)
and
and
(
get
(
'_p_changed'
)
==
False
)
(
get
(
'_p_changed'
)
==
False
)
):
):
self
.
_p_changed
=
True
self
.
_p_changed
=
True
data_manager
.
register
(
self
)
data_manager
.
register
(
self
)
...
@@ -179,7 +179,7 @@ class PersistentMetaClass(type):
...
@@ -179,7 +179,7 @@ class PersistentMetaClass(type):
def
__getstate__
(
self
):
def
__getstate__
(
self
):
return
(
self
.
__bases__
,
return
(
self
.
__bases__
,
dict
([(
k
,
v
)
for
(
k
,
v
)
in
self
.
__dict__
.
items
()
dict
([(
k
,
v
)
for
(
k
,
v
)
in
self
.
__dict__
.
items
()
if
not
(
k
.
startswith
(
'_p_'
)
if
not
(
k
.
startswith
(
'_p_'
)
or
k
.
startswith
(
'_v_'
)
or
k
.
startswith
(
'_v_'
)
...
@@ -187,9 +187,9 @@ class PersistentMetaClass(type):
...
@@ -187,9 +187,9 @@ class PersistentMetaClass(type):
)
)
]),
]),
)
)
__getstate__
=
_p_MethodDescr
(
__getstate__
)
__getstate__
=
_p_MethodDescr
(
__getstate__
)
def
__setstate__
(
self
,
state
):
def
__setstate__
(
self
,
state
):
self
.
__bases__
,
cdict
=
state
self
.
__bases__
,
cdict
=
state
cdict
=
dict
([(
k
,
v
)
for
(
k
,
v
)
in
cdict
.
items
()
cdict
=
dict
([(
k
,
v
)
for
(
k
,
v
)
in
cdict
.
items
()
...
@@ -208,14 +208,14 @@ class PersistentMetaClass(type):
...
@@ -208,14 +208,14 @@ class PersistentMetaClass(type):
for
k
in
to_remove
:
for
k
in
to_remove
:
delattr
(
self
,
k
)
delattr
(
self
,
k
)
for
k
,
v
in
cdict
.
items
():
for
k
,
v
in
cdict
.
items
():
setattr
(
self
,
k
,
v
)
setattr
(
self
,
k
,
v
)
self
.
_p_class_dict
=
_p_class_dict
self
.
_p_class_dict
=
_p_class_dict
self
.
_p_changed
=
False
self
.
_p_changed
=
False
__setstate__
=
_p_MethodDescr
(
__setstate__
)
__setstate__
=
_p_MethodDescr
(
__setstate__
)
def
_p_activate
(
self
):
def
_p_activate
(
self
):
...
...
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