[CalendarServer-changes] [847]
CalendarServer/trunk/twistedcaldav/directory/resource.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Dec 15 20:22:41 PST 2006
Revision: 847
http://trac.macosforge.org/projects/calendarserver/changeset/847
Author: wsanchez at apple.com
Date: 2006-12-15 20:22:41 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
locateChild() now calls provisionChild() if appropriate.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/resource.py
Modified: CalendarServer/trunk/twistedcaldav/directory/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/resource.py 2006-12-16 04:21:40 UTC (rev 846)
+++ CalendarServer/trunk/twistedcaldav/directory/resource.py 2006-12-16 04:22:41 UTC (rev 847)
@@ -22,6 +22,8 @@
__all__ = ["AutoProvisioningResourceMixIn"]
+from twisted.internet.defer import succeed, maybeDeferred
+
class AutoProvisioningResourceMixIn (object):
"""
Adds auto-provisioning to a Resource implementation.
@@ -41,15 +43,19 @@
"""
return None
- def locateChild(self, *args):
+ def provisionChild(self, name):
+ pass
+
+ def locateChild(self, request, segments):
"""
This implementation calls L{provision}, then super's L{locateChild}, thereby
ensuring that looked-up resources are provisioned.
"""
- super_method = super(AutoProvisioningResourceMixIn, self).locateChild
- d = self.provision()
- if d is None:
- return super_method(*args)
+ name = segments[0]
+ if name == "":
+ d = succeed(None)
else:
- d.addCallback(lambda _: super_method(*args))
- return d
+ d = maybeDeferred(self.provisionChild, name)
+ d.addCallback(lambda _: self.provision())
+ d.addCallback(lambda _: super(AutoProvisioningResourceMixIn, self).locateChild(request, segments))
+ return d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061215/2ed08c61/attachment.html
More information about the calendarserver-changes
mailing list