[Zope3-checkins] CVS: ZODB4/src/zodb - serialize.py:1.22.20.2
conflict.py:1.15.20.1
Jeremy Hylton
jeremy at zope.com
Wed Sep 17 10:37:36 EDT 2003
Update of /cvs-repository/ZODB4/src/zodb
In directory cvs.zope.org:/tmp/cvs-serv8059
Modified Files:
Tag: parentgeddon-branch
serialize.py conflict.py
Log Message:
Simplify the way data records for resolved objects are written.
Eliminate the need for the special adapter where obj.__class__ != type(obj).
=== ZODB4/src/zodb/serialize.py 1.22.20.1 => 1.22.20.2 ===
--- ZODB4/src/zodb/serialize.py:1.22.20.1 Wed Sep 17 09:00:47 2003
+++ ZODB4/src/zodb/serialize.py Wed Sep 17 10:37:34 2003
@@ -167,6 +167,14 @@
refs = findrefs(data)
return data, refs
+ def getStateFromResolved(self, ghost, state):
+ # This method is only used in the ResolvedObjectWriter subclass,
+ # but it is defined here to keep all the details of the data
+ # record format internal to this module.
+ data = self._dump(getClassMetadata(ghost), state)
+ refs = findrefs(data)
+ return data, refs
+
def _dump(self, classmeta, state):
# To reuse the existing cStringIO object, we must reset
# the file position to 0 and truncate the file after the
=== ZODB4/src/zodb/conflict.py 1.15 => 1.15.20.1 ===
--- ZODB4/src/zodb/conflict.py:1.15 Thu Jun 19 17:41:10 2003
+++ ZODB4/src/zodb/conflict.py Wed Sep 17 10:37:34 2003
@@ -28,34 +28,6 @@
ResolvedSerial = "rs"
-class ResolvedObjectAdapter:
- """Adapt an object's raw state to the ObjectWriter protocol.
-
- ObjectWriter uses an object's __class__ and __getstate__() method
- to determine how to pickle it. When conflict resolution occurs,
- there is no instantiated object; the code deals with the concrete
- state as returned by __getstate__(). This adapter allows the
- state to be passed to ObjectWriter without instantiating the
- object.
-
- This object should only be used in conjunction with the ObjectWriter.
- """
-
- def __init__(self, ghost, state):
- self._class = ghost.__class__
- self._state = state
- self._p_state = 0 # required to make getClassMetadata() happy
-
- def __getattribute__(self, name):
- if name == "__class__":
- return self._class
- else:
- _super = super(ResolvedObjectAdapter, self).__getattribute__
- return _super(name)
-
- def __getstate__(self):
- return self._state
-
class PersistentReference:
__slots__ = "oid",
@@ -191,7 +163,6 @@
resolved = resolve(old, committed, newstate)
writer = ResolvedObjectWriter()
- obj = ResolvedObjectAdapter(get_self(resolve), resolved)
- state = writer.getState(obj)
+ state = writer.getStateFromResolved(get_self(resolve), resolved)
writer.close()
return state
More information about the Zope3-Checkins
mailing list