[Zope-CVS] CVS: Products/ZopeVersionControl - container.py:1.3

Shane Hathaway cvs-admin at zope.org
Thu Oct 30 12:07:22 EST 2003


Update of /cvs-repository/Products/ZopeVersionControl
In directory cvs.zope.org:/tmp/cvs-serv8657

Modified Files:
	container.py 
Log Message:
New strategy for reference versioning.

References now get versioned along with their containers.  This puts us
in a nice situation where we only have to version or stage one object at 
a time.



=== Products/ZopeVersionControl/container.py 1.2 => 1.3 ===
--- Products/ZopeVersionControl/container.py:1.2	Thu Oct 30 11:30:49 2003
+++ Products/ZopeVersionControl/container.py	Thu Oct 30 12:06:52 2003
@@ -21,6 +21,16 @@
 from IVersionControl import IVersionedContainer
 
 
+try:
+    # Optional support for references.
+    from Products.References.Proxy import proxyReference
+except ImportError:
+    isProxy = None
+else:
+    def isProxy(obj):
+        return (proxyReference(obj) is not None)
+
+
 def getContainerVCAdapter(obj):
     """Returns an IVersionedContainer for any object.
 
@@ -89,16 +99,24 @@
         """Returns a mapping that maps item ID to (unwrapped) item."""
         res = {}
         for name, value in self.obj.objectItems():
+            if value is not None and isProxy is not None:
+                if isProxy(value):
+                    # Version references in their containers.
+                    continue
             res[name] = aq_base(value)
         return res
 
+
     def removeVCItems(self):
         """Removes all versionable items from this container."""
         obj = self.obj
-        for name in obj.objectIds():
+        removed = {}
+        for name, value in self.getVCItems().items():
             obj._delOb(name)
+            removed[name] = 1
         if obj._objects:
-            obj._objects = ()
+            obj._objects = tuple([info for info in obj._objects
+                                  if not removed.has_key(info['id'])])
 
     def restoreVCItems(self, dict):
         """Restores items to this container."""




More information about the Zope-CVS mailing list