[CalendarServer-changes] [6410] CalendarServer/trunk/twistedcaldav/resource.py
source_changes at macosforge.org
source_changes at macosforge.org
Thu Oct 7 15:29:50 PDT 2010
Revision: 6410
http://trac.macosforge.org/projects/calendarserver/changeset/6410
Author: sagen at apple.com
Date: 2010-10-07 15:29:47 -0700 (Thu, 07 Oct 2010)
Log Message:
-----------
Create pubsub node when client asks for the corresponding DAV properties.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/resource.py
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2010-10-07 19:39:00 UTC (rev 6409)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2010-10-07 22:29:47 UTC (rev 6410)
@@ -78,8 +78,9 @@
from twistedcaldav.icaldav import ICalDAVResource, ICalendarPrincipalResource
from twistedcaldav.index import SyncTokenValidException, Index
from twistedcaldav.linkresource import LinkResource
-from twistedcaldav.notify import getPubSubConfiguration, getPubSubPath,\
- getPubSubXMPPURI, getPubSubHeartbeatURI, getPubSubAPSConfiguration
+from twistedcaldav.notify import (getPubSubConfiguration, getPubSubPath,
+ getPubSubXMPPURI, getPubSubHeartbeatURI, getPubSubAPSConfiguration,
+ getNodeCacher)
from twistedcaldav.sharing import SharedCollectionMixin, SharedHomeMixin
from twistedcaldav.vcard import Component as vComponent
from twistedcaldav.vcardindex import AddressBookIndex
@@ -2258,6 +2259,7 @@
children.update(self._newStoreHome.listChildren())
return children
+ @inlineCallbacks
def readProperty(self, property, request):
if type(property) is tuple:
qname = property
@@ -2299,35 +2301,54 @@
)
)
- return succeed(customxml.PubSubPushTransportsProperty(*children))
+ returnValue(customxml.PubSubPushTransportsProperty(*children))
else:
- return succeed(customxml.PubSubPushTransportsProperty())
+ returnValue(customxml.PubSubPushTransportsProperty())
if qname == (customxml.calendarserver_namespace, "pushkey"):
notifierID = self._newStoreHome.notifierID()
if notifierID is not None and config.Notifications.Services.XMPPNotifier.Enabled:
pubSubConfiguration = getPubSubConfiguration(config)
nodeName = getPubSubPath(notifierID, pubSubConfiguration)
- return succeed(customxml.PubSubXMPPPushKeyProperty(nodeName))
+
+ # Create the pubsub node so client has something to subscribe
+ # to
+ try:
+ (yield getNodeCacher().waitForNode(
+ self._newStoreHome._notifier, nodeName))
+ except NodeCreationException, e:
+ self.log_warn(e)
+
+ returnValue(customxml.PubSubXMPPPushKeyProperty(nodeName))
else:
- return succeed(customxml.PubSubXMPPPushKeyProperty())
+ returnValue(customxml.PubSubXMPPPushKeyProperty())
if qname == (customxml.calendarserver_namespace, "xmpp-uri"):
notifierID = self._newStoreHome.notifierID()
if notifierID is not None and config.Notifications.Services.XMPPNotifier.Enabled:
pubSubConfiguration = getPubSubConfiguration(config)
- return succeed(customxml.PubSubXMPPURIProperty(
+
+ # Create the pubsub node so client has something to subscribe
+ # to
+ nodeName = getPubSubPath(notifierID, pubSubConfiguration)
+ try:
+ (yield getNodeCacher().waitForNode(
+ self._newStoreHome._notifier, nodeName))
+ except NodeCreationException, e:
+ self.log_warn(e)
+
+ returnValue(customxml.PubSubXMPPURIProperty(
getPubSubXMPPURI(notifierID, pubSubConfiguration)))
else:
- return succeed(customxml.PubSubXMPPURIProperty())
+ returnValue(customxml.PubSubXMPPURIProperty())
elif qname == (customxml.calendarserver_namespace, "xmpp-heartbeat-uri"):
pubSubConfiguration = getPubSubConfiguration(config)
if pubSubConfiguration['enabled']:
- return succeed(
+ returnValue(
customxml.PubSubHeartbeatProperty(
customxml.PubSubHeartbeatURIProperty(
getPubSubHeartbeatURI(pubSubConfiguration)
@@ -2338,17 +2359,17 @@
)
)
else:
- return succeed(customxml.PubSubHeartbeatURIProperty())
+ returnValue(customxml.PubSubHeartbeatURIProperty())
elif qname == (customxml.calendarserver_namespace, "xmpp-server"):
pubSubConfiguration = getPubSubConfiguration(config)
if pubSubConfiguration['enabled']:
- return succeed(customxml.PubSubXMPPServerProperty(
+ returnValue(customxml.PubSubXMPPServerProperty(
pubSubConfiguration['xmpp-server']))
else:
- return succeed(customxml.PubSubXMPPServerProperty())
+ returnValue(customxml.PubSubXMPPServerProperty())
- return super(CommonHomeResource, self).readProperty(property, request)
+ returnValue((yield super(CommonHomeResource, self).readProperty(property, request)))
##
# ACL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20101007/a1377c6f/attachment-0001.html>
More information about the calendarserver-changes
mailing list