[CalendarServer-changes] [5227] CalendarServer/branches/users/cdaboo/shared-calendars-5187/ twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 1 21:06:52 PST 2010
Revision: 5227
http://trac.macosforge.org/projects/calendarserver/changeset/5227
Author: cdaboo at apple.com
Date: 2010-03-01 21:06:49 -0800 (Mon, 01 Mar 2010)
Log Message:
-----------
Per-user webdav cached properties.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/memcacheprops.py
CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/test_resource.py
CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/util.py
Modified: CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/memcacheprops.py
===================================================================
--- CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/memcacheprops.py 2010-03-01 21:23:11 UTC (rev 5226)
+++ CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/memcacheprops.py 2010-03-02 05:06:49 UTC (rev 5227)
@@ -77,7 +77,7 @@
# "/path/to/resource/file":
# (
# {
- # (namespace, name): property,
+ # (namespace, name, uid): property,
# ...,
# },
# memcache_token,
@@ -193,8 +193,8 @@
propertyStore = child.deadProperties()
props = {}
- for qname in propertyStore.list(cache=False):
- props[qname] = propertyStore.get(qname, cache=False)
+ for pnamespace, pname, puid in propertyStore.list(filterByUID=False, cache=False):
+ props[(pnamespace, pname, puid,)] = propertyStore.get((pnamespace, pname,), uid=puid, cache=False)
cache[child.fp.path] = props
@@ -202,16 +202,18 @@
return cache
- def setProperty(self, child, property, delete=False):
+ def setProperty(self, child, property, uid, delete=False):
propertyCache, key, childCache, token = self.childCache(child)
if delete:
qname = property
- if childCache.has_key(qname):
- del childCache[qname]
+ qnameuid = qname + (uid,)
+ if childCache.has_key(qnameuid):
+ del childCache[qnameuid]
else:
qname = property.qname()
- childCache[qname] = property
+ qnameuid = qname + (uid,)
+ childCache[qnameuid] = property
client = self.memcacheClient()
@@ -239,20 +241,24 @@
propertyCache, key, childCache, token = self.childCache(child)
if delete:
- if childCache.has_key(qname):
- del childCache[qname]
+ if childCache.has_key(qnameuid):
+ del childCache[qnameuid]
else:
- childCache[qname] = property
+ childCache[qnameuid] = property
else:
log.error("memcacheprops setProperty had too many failures")
delattr(self, "_propertyCache")
- raise MemcacheError("Unable to %s property {%s}%s on %s"
- % ("delete" if delete else "set",
- qname[0], qname[1], child))
+ raise MemcacheError("Unable to %s property %s{%s}%s on %s" % (
+ "delete" if delete else "set",
+ uid if uid else "",
+ qname[0],
+ qname[1],
+ child
+ ))
- def deleteProperty(self, child, qname):
- return self.setProperty(child, qname, delete=True)
+ def deleteProperty(self, child, qname, uid):
+ return self.setProperty(child, qname, uid, delete=True)
def flushCache(self, child):
path = child.fp.path
@@ -286,49 +292,72 @@
def flushCache(self):
self.parentPropertyCollection.flushCache(self.child)
- def get(self, qname, cache=True):
+ def get(self, qname, uid=None, cache=True):
if cache:
propertyCache = self.propertyCache()
- if qname in propertyCache:
- return propertyCache[qname]
+ qnameuid = qname + (uid,)
+ if qnameuid in propertyCache:
+ return propertyCache[qnameuid]
else:
raise HTTPError(StatusResponse(
responsecode.NOT_FOUND,
- "No such property: {%s}%s" % qname
+ "No such property: %s{%s}%s" % (uid if uid else "", qname[0], qname[1],)
))
- self.log_debug("Read for %s on %s"
- % (qname, self.childPropertyStore.resource.fp.path))
- return self.childPropertyStore.get(qname)
+ self.log_debug("Read for %s%s on %s" % (
+ ("{%s}:" % (uid,)) if uid else "",
+ qname,
+ self.childPropertyStore.resource.fp.path
+ ))
+ return self.childPropertyStore.get(qname, uid=uid)
- def set(self, property):
- self.log_debug("Write for %s on %s"
- % (property.qname(), self.childPropertyStore.resource.fp.path))
+ def set(self, property, uid=None):
+ self.log_debug("Write for %s%s on %s" % (
+ ("{%s}:" % (uid,)) if uid else "",
+ property.qname(),
+ self.childPropertyStore.resource.fp.path
+ ))
- self.parentPropertyCollection.setProperty(self.child, property)
- self.childPropertyStore.set(property)
+ self.parentPropertyCollection.setProperty(self.child, property, uid)
+ self.childPropertyStore.set(property, uid=uid)
- def delete(self, qname):
- self.log_debug("Delete for %s on %s"
- % (qname, self.childPropertyStore.resource.fp.path))
+ def delete(self, qname, uid=None):
+ self.log_debug("Delete for %s%s on %s" % (
+ ("{%s}:" % (uid,)) if uid else "",
+ qname,
+ self.childPropertyStore.resource.fp.path
+ ))
- self.parentPropertyCollection.deleteProperty(self.child, qname)
- self.childPropertyStore.delete(qname)
+ self.parentPropertyCollection.deleteProperty(self.child, qname, uid)
+ self.childPropertyStore.delete(qname, uid=uid)
- def contains(self, qname, cache=True):
+ def contains(self, qname, uid=None, cache=True):
if cache:
propertyCache = self.propertyCache()
- return qname in propertyCache
+ qnameuid = qname + (uid,)
+ return qnameuid in propertyCache
- self.log_debug("Contains for %s"
- % (self.childPropertyStore.resource.fp.path,))
- return self.childPropertyStore.contains(qname)
+ self.log_debug("Contains for %s%s on %s" % (
+ ("{%s}:" % (uid,)) if uid else "",
+ qname,
+ self.childPropertyStore.resource.fp.path,
+ ))
+ return self.childPropertyStore.contains(qname, uid=uid)
- def list(self, cache=True):
+ def list(self, uid=None, filterByUID=True, cache=True):
if cache:
propertyCache = self.propertyCache()
- return propertyCache.iterkeys()
+ results = propertyCache.keys()
+ if filterByUID:
+ return [
+ (namespace, name)
+ for namespace, name, propuid in results
+ if propuid == uid
+ ]
+ else:
+ return results
+
self.log_debug("List for %s"
% (self.childPropertyStore.resource.fp.path,))
- return self.childPropertyStore.list()
+ return self.childPropertyStore.list(uid=uid, filterByUID=filterByUID)
Modified: CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/test_resource.py
===================================================================
--- CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/test_resource.py 2010-03-01 21:23:11 UTC (rev 5226)
+++ CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/test_resource.py 2010-03-02 05:06:49 UTC (rev 5227)
@@ -22,7 +22,7 @@
class StubProperty(object):
def qname(self):
- return "StubQname"
+ return "StubQnamespace", "StubQname"
class CalDAVResourceTests(TestCase):
@@ -34,5 +34,5 @@
def test_writeDeadPropertyWritesProperty(self):
prop = StubProperty()
self.resource.writeDeadProperty(prop)
- self.assertEquals(self.resource._dead_properties.get("StubQname"),
+ self.assertEquals(self.resource._dead_properties.get(("StubQnamespace", "StubQname")),
prop)
Modified: CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/util.py
===================================================================
--- CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/util.py 2010-03-01 21:23:11 UTC (rev 5226)
+++ CalendarServer/branches/users/cdaboo/shared-calendars-5187/twistedcaldav/test/util.py 2010-03-02 05:06:49 UTC (rev 5227)
@@ -196,24 +196,35 @@
self._properties = {}
self.resource = _FauxResource()
- def get(self, qname):
- data = self._properties.get(qname)
+ def get(self, qname, uid=None):
+ qnameuid = qname + (uid,)
+ data = self._properties.get(qnameuid)
if data is None:
raise HTTPError(StatusResponse(404, "No such property"))
return data
- def set(self, property):
- self._properties[property.qname()] = property
+ def set(self, property, uid=None):
+ qnameuid = property.qname() + (uid,)
+ self._properties[qnameuid] = property
- def delete(self, qname):
+ def delete(self, qname, uid=None):
try:
- del self._properties[qname]
+ qnameuid = qname + (uid,)
+ del self._properties[qnameuid]
except KeyError:
pass
- def list(self):
- return self._properties.iterkeys()
+ def list(self, uid=None, filterByUID=True):
+ results = self._properties.iterkeys()
+ if filterByUID:
+ return [
+ (namespace, name)
+ for namespace, name, propuid in results
+ if propuid == uid
+ ]
+ else:
+ return results
class StubCacheChangeNotifier(object):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100301/55561b98/attachment-0001.html>
More information about the calendarserver-changes
mailing list