[CMF-checkins] CVS: CMF/CMFStaging - LockTool.py:1.11

Shane Hathaway shane@zope.com
Mon, 28 Apr 2003 15:29:05 -0400


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

Modified Files:
	LockTool.py 
Log Message:
Fixed interaction with WebDAV locks.  wl_lockValues() apparently returns expired locks and you have to check the validity of each one.

=== CMF/CMFStaging/LockTool.py 1.10 => 1.11 ===
--- CMF/CMFStaging/LockTool.py:1.10	Mon Feb 24 14:27:02 2003
+++ CMF/CMFStaging/LockTool.py	Mon Apr 28 15:29:04 2003
@@ -62,10 +62,13 @@
     # of autoversioning described in the DeltaV introduction.
     # http://www.webdav.org/deltav/WWW10/deltav-intro.htm
     auto_version = 1
+    timeout_days = 14  # 2 weeks
 
     _properties = (
         {'id': 'auto_version', 'type': 'boolean', 'mode': 'w',
          'label': 'Auto checkout and checkin using portal_versions'},
+        {'id': 'timeout_days', 'type': 'int', 'mode': 'w',
+         'label': 'Lock timeout in days'},
         )
 
     #
@@ -93,7 +96,7 @@
                     object = vt.checkout(object)
 
         user = getSecurityManager().getUser()
-        lockitem = LockItem(user)
+        lockitem = LockItem(user, timeout=(self.timeout_days * 86400))
         object.wl_setLock(lockitem.getLockToken(), lockitem)
 
 
@@ -142,11 +145,13 @@
         values = object.wl_lockValues()
         if not values:
             return ''
-
-        creator = values[0].getCreator()
-        if creator:
-            return creator[1]  # The user id without the path
-        return ''  # An expired lock?
+        for lock in values:
+            if lock.isValid():
+                creator = lock.getCreator()
+                if creator:
+                    return creator[1]  # The user id without the path
+        # All of the locks are expired or invalid
+        return ''
 
 
     security.declarePublic('isLockedOut')