[CMF-checkins] CVS: CMF/CMFStaging - VersionsTool.py:1.7

Shane Hathaway shane@cvs.zope.org
Thu, 11 Jul 2002 18:24:28 -0400


Update of /cvs-repository/CMF/CMFStaging
In directory cvs.zope.org:/tmp/cvs-serv6237

Modified Files:
	VersionsTool.py 
Log Message:
- checkin() doesn't mind anymore if the object is already checked in.

- Added getHistoryId(), so that other tools can use the version history ID
  for other purposes.


=== CMF/CMFStaging/VersionsTool.py 1.6 => 1.7 ===
 
     security.declareProtected(UseVersionControl, 'checkin')
     def checkin(self, object, message=''):
-        """Checks in a new version on the development stage."""
+        """Checks in a new version."""
         # Make sure we copy the current data.
         # XXX ZopeVersionControl tries to do this but isn't quite correct yet.
         get_transaction().commit(1)
@@ -123,7 +123,9 @@
         if not repo.isUnderVersionControl(object):
             repo.applyVersionControl(object)
         else:
-            repo.checkinResource(object, message)
+            info = repo.getVersionInfo(object)
+            if info.status == info.CHECKED_OUT:
+                repo.checkinResource(object, message)
 
 
     security.declareProtected(UseVersionControl, 'isUnderVersionControl')
@@ -184,6 +186,13 @@
             return repo.getVersionInfo(object).version_id
         else:
             return ''
+
+
+    security.declareProtected(UseVersionControl, 'getHistoryId')
+    def getHistoryId(self, object):
+        """Returns the version history ID of the object."""
+        repo = self._getVersionRepository()
+        return repo.getVersionInfo(object).history_id
 
 
     security.declareProtected(UseVersionControl, 'revertToVersion')