Commit 462ba6d5 authored by Shane Hathaway's avatar Shane Hathaway

Prevented accidental transactions from the locking code.

parent de18c80a
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__version__ = "$Revision: 1.5 $"[11:-2] __version__ = "$Revision: 1.6 $"[11:-2]
from WriteLockInterface import WriteLockInterface, LockItemInterface from WriteLockInterface import WriteLockInterface, LockItemInterface
from EtagSupport import EtagSupport from EtagSupport import EtagSupport
...@@ -120,7 +120,7 @@ class LockableItem(EtagSupport): ...@@ -120,7 +120,7 @@ class LockableItem(EtagSupport):
security.setPermissionDefault('WebDAV Unlock items',('Manager','Owner',)) security.setPermissionDefault('WebDAV Unlock items',('Manager','Owner',))
def wl_lockmapping(self, killinvalids=0): def wl_lockmapping(self, killinvalids=0, create=0):
""" if 'killinvalids' is 1, locks who are no longer valid """ if 'killinvalids' is 1, locks who are no longer valid
will be deleted """ will be deleted """
...@@ -128,7 +128,11 @@ class LockableItem(EtagSupport): ...@@ -128,7 +128,11 @@ class LockableItem(EtagSupport):
except: locks = None except: locks = None
if locks is None: if locks is None:
locks = self._dav_writelocks = PersistentMapping() if create:
locks = self._dav_writelocks = PersistentMapping()
else:
# Don't generate a side effect transaction.
locks = {}
return locks return locks
elif killinvalids: elif killinvalids:
# Delete invalid locks # Delete invalid locks
...@@ -165,7 +169,7 @@ class LockableItem(EtagSupport): ...@@ -165,7 +169,7 @@ class LockableItem(EtagSupport):
else: return 0 else: return 0
def wl_setLock(self, locktoken, lock): def wl_setLock(self, locktoken, lock):
locks = self.wl_lockmapping() locks = self.wl_lockmapping(create=1)
if LockItemInterface.isImplementedBy(lock): if LockItemInterface.isImplementedBy(lock):
if locktoken == lock.getLockToken(): if locktoken == lock.getLockToken():
locks[locktoken] = lock locks[locktoken] = lock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment