[Zope-CVS] CVS: Products/AdaptableStorage/serial_ofs - FolderItems.py:1.11
Shane Hathaway
shane@zope.com
Fri, 10 Jan 2003 13:31:45 -0500
Update of /cvs-repository/Products/AdaptableStorage/serial_ofs
In directory cvs.zope.org:/tmp/cvs-serv2666/serial_ofs
Modified Files:
FolderItems.py
Log Message:
Made move/rename work with objects from the filesystem. It took some tricks,
but the tricks have unit tests, so it's not so bad. :-)
- Improved reporting of errors in failed attempts to move objects.
- Added a _setOb() patch that copies objects instead of moving or renaming
them, if that's the only thing that can be done.
- Refactored ZODB branch copying into a simple function, copyOf().
- Made FolderItems set a marker that indicates to _setOb() that it has to
copy rather than move.
Since SQL gateways use FolderItemsByKeychain instead of FolderItems, it has
always been possible to move/rename in a SQL database. None of these
changes affect SQL operations.
=== Products/AdaptableStorage/serial_ofs/FolderItems.py 1.10 => 1.11 ===
--- Products/AdaptableStorage/serial_ofs/FolderItems.py:1.10 Mon Jan 6 10:36:50 2003
+++ Products/AdaptableStorage/serial_ofs/FolderItems.py Fri Jan 10 13:31:11 2003
@@ -23,7 +23,9 @@
from Acquisition import aq_base
from OFS.ObjectManager import ObjectManager
-from mapper_public import IAspectSerializer, RowSequenceSchema
+from mapper_public \
+ import IAspectSerializer, RowSequenceSchema, SerializationError
+from utils import copyOf
class FolderItems:
@@ -47,14 +49,23 @@
for id, subob in object.objectItems():
base = aq_base(subob)
keychain = event.identifyObject(base)
- if keychain is None:
- keychain = event.makeKeychain(id, 0)
+ expected = event.makeKeychain(id, 0)
+ if keychain is not None and keychain != expected:
+ raise SerializationError(
+ "Subobject %s has unexpected keychain, %s. Expected %s." %
+ (repr(base), repr(keychain), repr(expected)))
+ keychain = expected
event.notifySerializedRef(id, base, 1, keychain)
state.append((id,))
+ event.ignoreAttribute('_use_fixed_oids_')
+ # Add a marker that tells the folder it has to move/rename
+ # in a special way. The _setOb patch sees this attribute.
+ object._use_fixed_oids_ = 1
return state
def deserialize(self, object, event, state):
assert isinstance(object, ObjectManager)
+ object._use_fixed_oids_ = 1
for (id,) in state:
keychain = event.makeKeychain(id, 0)
subob = event.dereference(id, keychain)