[Zope-CVS] CVS: Products/AdaptableStorage - Zope2FS.py:1.12 Zope2SQL.py:1.4

Shane Hathaway shane@zope.com
Fri, 13 Dec 2002 15:42:33 -0500


Update of /cvs-repository/Products/AdaptableStorage
In directory cvs.zope.org:/tmp/cvs-serv32288

Modified Files:
	Zope2FS.py Zope2SQL.py 
Log Message:
Hopefully solved the problem of unmanaged persistent objects.

Because AdaptableStorage lets the mappers choose their own persistence
boundaries, some objects that inherit from Persistent may be unknown
to ZODB, even though they are in the database.  I call these unmanaged
persistent objects.

The problem with unmanaged persistent objects surfaces when you change
them without changing their container.  For example, if you add an
item to a BTree, the BTree object (which is managed) does not get
changed, but rather a contained Bucket object (which is often
unmanaged).  We really need the BTree to be notified when the Buckets
change.

To solve this, certain aspect serializers (currently only
RemainderSerializer) now detect unmanaged persistent objects and addq
them to a list.  ZODB looks over this list and assigns them a one-off
"_p_jar" with a register() method.  This special register() method
just sets the _p_changed attribute of the managed object, notifying
ZODB that it must be saved.

I think this is the best solution, even though it's awfully complex to
explain.  The change involved moving the RemainingState aspect to the
"zodb" subpackage, since it already depended on the particulars of the
Persistent base class anyway.  It also required changing
ObjectSerializer so that the event object gets constructed by the
caller, which is appropriate, I think.

Also made some minor changes.


=== Products/AdaptableStorage/Zope2FS.py 1.11 => 1.12 ===
--- Products/AdaptableStorage/Zope2FS.py:1.11	Wed Dec 11 18:07:23 2002
+++ Products/AdaptableStorage/Zope2FS.py	Fri Dec 13 15:42:02 2002
@@ -21,12 +21,13 @@
      import ObjectSerializer, ObjectGateway, ObjectMapper
 from serial_std.public \
      import RollCall, FixedPersistentMapping, IgnoredAttribute, \
-     RemainingState, PathKeychainGenerator, AnyObjectSerializer, \
+     PathKeychainGenerator, AnyObjectSerializer, \
      StringDataAttribute
 from serial_ofs.public import FolderItems, MetaTypeClassifier, IdAttribute, \
      FilePData
 from gateway_fs.public import FSConnection, FSDirectoryItems, FSAutoId, \
      FSSectionData, FSClassificationSection, FSFileData
+from zodb.public import RemainingState
 
 
 def createMapper(basepath, volatile=1):


=== Products/AdaptableStorage/Zope2SQL.py 1.3 => 1.4 ===
--- Products/AdaptableStorage/Zope2SQL.py:1.3	Tue Dec 10 17:51:37 2002
+++ Products/AdaptableStorage/Zope2SQL.py	Fri Dec 13 15:42:02 2002
@@ -21,11 +21,12 @@
      import ObjectSerializer, ObjectGateway, ObjectMapper
 from serial_std.public \
      import RollCall, FixedPersistentMapping, IgnoredAttribute, \
-     RemainingState, PathKeychainGenerator, AnyObjectSerializer
+     PathKeychainGenerator, AnyObjectSerializer
 from serial_ofs.public import FolderItemsByKeychain, MetaTypeClassifier, \
      IdAttribute
 from gateway_sql.public import PsycopgConnection, SQLClassification, \
      SQLFolderItems, SQLItemId, SQLKeychainGenerator, SQLRemainder
+from zodb.public import RemainingState
 
 
 def createMapper(params='', table_prefix='zodb', volatile=1):