[Zope-CVS] CVS: Products/ZopeVersionControl - Repository.py:1.3 Version.py:1.6 VersionHistory.py:1.4

Shane Hathaway shane@cvs.zope.org
Wed, 12 Jun 2002 13:57:43 -0400


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

Modified Files:
	Repository.py Version.py VersionHistory.py 
Log Message:
Instead of setting _p_jar attributes directly, used subtransactions to
prepare for object copying.


=== Products/ZopeVersionControl/Repository.py 1.2 => 1.3 ===
         history_id = '%0.09d' % (len(self._histories) + 1)
         history = ZopeVersionHistory(history_id, object)
-        history._p_jar = self._p_jar
         self._histories[history_id] = history
         return history.__of__(self)
 


=== Products/ZopeVersionControl/Version.py 1.5 => 1.6 ===
         # TODO: this should probably use Utility._findModificationTime,
         # though we should gauge the impact on performance.
-        if getattr(object, '_p_changed', 0):
+        if (getattr(object, '_p_changed', 0) or
+            getattr(object, '_p_jar', None) is None or
+            getattr(container, '_p_jar', None) is None):
             get_transaction().commit(1)
         file = tempfile.TemporaryFile()
         object._p_jar.exportFile(object._p_oid, file)


=== Products/ZopeVersionControl/VersionHistory.py 1.3 => 1.4 ===
             version_id = '%d' % (len(branch) + 1)
         version = ZopeVersion(version_id, object)
-        version._p_jar = self._p_jar
-        version.saveState(object)
 
         # Update the  predecessor, successor and branch relationships.
         # This is something of a hedge against the future. Versions will
@@ -126,6 +124,9 @@
 
         branch.append(version)
         self._versions[version_id] = version
+        # Call saveState() only after version has been linked into the
+        # database, ensuring it goes into the correct database.
+        version.saveState(object)
         return version.__of__(self)
 
     security.declarePrivate('hasVersionId')