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

Andrew Sawyers andrew@zope.com
Tue, 11 Feb 2003 11:41:57 -0500


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

Modified Files:
	LockTool.py 
Log Message:
*I needed the ability for allowing 'admin' types to break a lock - I hooked this into workflow and rolemappings during transitions.


=== Releases/CMF/CMFStaging/LockTool.py 1.7 => 1.8 ===
--- Releases/CMF/CMFStaging/LockTool.py:1.7	Fri Nov  1 13:08:54 2002
+++ Releases/CMF/CMFStaging/LockTool.py	Tue Feb 11 11:41:55 2003
@@ -34,6 +34,7 @@
 # Permission names
 LockObjects = 'WebDAV Lock items'
 UnlockObjects = 'WebDAV Unlock items'
+BreakLock = 'Manage portal'
 
 _wwwdir = os.path.join(os.path.dirname(__file__), 'www') 
 
@@ -96,6 +97,19 @@
         lockitem = LockItem(user)
         object.wl_setLock(lockitem.getLockToken(), lockitem)
 
+
+    security.declareProtected(UnlockObjects, 'breaklock')
+    def breaklock(self, object, message=''):
+        """emergency breaklock...."""
+        locker = self.locker(object)
+        if not _checkPermission(UnlockObjects, object):
+            raise LockingError, ("You cannot unlock %s:  lock is held by %s" % 
+                                 (pathOf(object), locker))
+        object.wl_clearLocks()
+        if self.auto_version:
+            vt = getToolByName(self, 'portal_versions', None)
+            if vt is not None:
+                vt.checkin(object, message)
 
     security.declareProtected(UnlockObjects, 'unlock')
     def unlock(self, object, message=''):