Commit d178a671 authored by Andreas Jung's avatar Andreas Jung

Collector #126: merge from 2.5 branch fixes LOCK-stealing problem

with cadaver
parent bca3e8d5
......@@ -12,7 +12,7 @@
##############################################################################
"""Property sheets"""
__version__='$Revision: 1.80 $'[11:-2]
__version__='$Revision: 1.81 $'[11:-2]
import time, string, App.Management, Globals
from webdav.WriteLockInterface import WriteLockInterface
......@@ -26,6 +26,7 @@ from ExtensionClass import Base
from Globals import Persistent
from Traversable import Traversable
from Acquisition import aq_base
from AccessControl import getSecurityManager
class View(App.Management.Tabs, Base):
"""A view of an object, typically used for management purposes
......@@ -541,13 +542,24 @@ class DAVProperties(Virtual, PropertySheet, View):
' </n:lockentry>\n '
def dav__lockdiscovery(self):
security = getSecurityManager()
user = security.getUser().getUserName()
vself = self.v_self()
out = '\n'
if WriteLockInterface.isImplementedBy(vself):
locks = vself.wl_lockValues(killinvalids=1)
for lock in locks:
out = '%s\n%s' % (out, lock.asLockDiscoveryProperty('n'))
creator = lock.getCreator()[-1]
if creator == user: fake=0
else: fake=1
out = '%s\n%s' % (out, lock.asLockDiscoveryProperty('n',fake=fake))
out = '%s\n' % out
return out
......
......@@ -11,8 +11,7 @@
#
##############################################################################
__version__ = "$Revision: 1.5 $"[11:-2]
__version__ = "$Revision: 1.6 $"[11:-2]
from Globals import Persistent
from WriteLockInterface import LockItemInterface
......@@ -142,7 +141,10 @@ class LockItem(Persistent):
def getLockScope(self):
return self._lockscope
def asLockDiscoveryProperty(self, ns='d'):
def asLockDiscoveryProperty(self, ns='d',fake=0):
if fake: token = 'this-is-a-faked-no-permission-token'
else: token = self._token
s = (' <%(ns)s:activelock>\n'
' <%(ns)s:locktype><%(ns)s:%(locktype)s/></%(ns)s:locktype>\n'
' <%(ns)s:lockscope><%(ns)s:%(lockscope)s/></%(ns)s:lockscope>\n'
......@@ -160,11 +162,12 @@ class LockItem(Persistent):
'depth': self._depth,
'owner': self._owner,
'timeout': self.getTimeoutString(),
'locktoken': self._token,
'locktoken': token,
}
return s
def asXML(self):
s = """<?xml version="1.0" encoding="utf-8" ?>
<d:prop xmlns:d="DAV:">
<d:lockdiscovery>
......
......@@ -13,11 +13,14 @@
"""Commonly used functions for WebDAV support modules."""
__version__='$Revision: 1.14 $'[11:-2]
__version__='$Revision: 1.15 $'[11:-2]
import time, urllib, re
from App.Common import iso8601_date, rfc850_date, rfc1123_date
from App.Common import aq_base
import random
_randGen = random.Random(time.time())
def absattr(attr):
if callable(attr):
......@@ -53,10 +56,10 @@ def urlbase(url, ftype=urllib.splittype, fhost=urllib.splithost):
def generateLockToken():
# Generate a lock token
# XXX This is simple right now, just lifted from the original shortcut
# in Resource.dav__genlocktoken, but should be replaced by something
# better.
return 'AA9F6414-1D77-11D3-B825-00105A989226:%.03f' % time.time()
return '%s-%s-00105A989226:%.03f' % \
(_randGen.random(),_randGen.random(),time.time())
def tokenFinder(token):
# takes a string like '<opaquelocktoken:afsdfadfadf> and returns the token
......
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