[CalendarServer-changes] [4021] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Apr 15 12:18:42 PDT 2009
Revision: 4021
http://trac.macosforge.org/projects/calendarserver/changeset/4021
Author: sagen at apple.com
Date: 2009-04-15 12:18:39 -0700 (Wed, 15 Apr 2009)
Log Message:
-----------
Principal resources which were marked as not enabled for calendaring were missing DAV properties for email address, first and last name. This fixes that.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/principal.py
CalendarServer/trunk/twistedcaldav/resource.py
Modified: CalendarServer/trunk/twistedcaldav/directory/principal.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/principal.py 2009-04-14 22:22:22 UTC (rev 4020)
+++ CalendarServer/trunk/twistedcaldav/directory/principal.py 2009-04-15 19:18:39 UTC (rev 4021)
@@ -58,6 +58,7 @@
from twistedcaldav.directory.idirectory import IDirectoryService
from twistedcaldav.log import Logger
from twistedcaldav import caldavxml, customxml
+from twistedcaldav.customxml import calendarserver_namespace
from twistedcaldav.directory.wiki import getWikiACL
from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
@@ -490,6 +491,13 @@
"""
Directory principal resource.
"""
+
+ liveProperties = tuple(DAVPrincipalResource.liveProperties) + (
+ (calendarserver_namespace, "first-name" ),
+ (calendarserver_namespace, "last-name" ),
+ (calendarserver_namespace, "email-address-set"),
+ )
+
cacheNotifierFactory = DisabledCacheNotifier
def __init__(self, parent, record):
@@ -521,6 +529,38 @@
def __str__(self):
return "(%s) %s" % (self.record.recordType, self.record.shortNames[0])
+ @inlineCallbacks
+ def readProperty(self, property, request):
+ if type(property) is tuple:
+ qname = property
+ else:
+ qname = property.qname()
+
+ namespace, name = qname
+
+ if namespace == calendarserver_namespace:
+ if name == "first-name":
+ firstName = self.record.firstName
+ if firstName:
+ returnValue(customxml.FirstNameProperty(firstName))
+ else:
+ returnValue(None)
+
+ elif name == "last-name":
+ lastName = self.record.lastName
+ if lastName:
+ returnValue(customxml.LastNameProperty(lastName))
+ else:
+ returnValue(None)
+
+ elif name == "email-address-set":
+ returnValue(customxml.EmailAddressSet(
+ *[customxml.EmailAddressProperty(addr) for addr in self.record.emailAddresses]
+ ))
+
+ result = (yield super(DirectoryPrincipalResource, self).readProperty(property, request))
+ returnValue(result)
+
def deadProperties(self):
if not hasattr(self, "_dead_properties"):
self._dead_properties = NonePropertyStore(self)
@@ -752,6 +792,24 @@
Directory calendar principal resource.
"""
+ @property
+ def liveProperties(self):
+ # This needs to be a dynamic property because CalendarPrincipalResource
+ # liveProperties changes on the fly (drop box enabling)
+ return (
+ tuple(DirectoryPrincipalResource.liveProperties) +
+ tuple(CalendarPrincipalResource.liveProperties)
+ )
+
+
+ @inlineCallbacks
+ def readProperty(self, property, request):
+ # Ouch, multiple inheritance.
+ result = (yield DirectoryPrincipalResource.readProperty(self, property, request))
+ if not result:
+ result = (yield CalendarPrincipalResource.readProperty(self, property, request))
+ returnValue(result)
+
def extraDirectoryBodyItems(self, request):
return "".join((
"""\nCalendar homes:\n""" , format_list(format_link(u) for u in self.calendarHomeURLs()),
Modified: CalendarServer/trunk/twistedcaldav/resource.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/resource.py 2009-04-14 22:22:22 UTC (rev 4020)
+++ CalendarServer/trunk/twistedcaldav/resource.py 2009-04-15 19:18:39 UTC (rev 4021)
@@ -824,9 +824,6 @@
(caldav_namespace, "schedule-inbox-URL" ),
(caldav_namespace, "schedule-outbox-URL" ),
(caldav_namespace, "calendar-user-type" ),
- (calendarserver_namespace, "first-name" ),
- (calendarserver_namespace, "last-name" ),
- (calendarserver_namespace, "email-address-set"),
(calendarserver_namespace, "calendar-proxy-read-for" ),
(calendarserver_namespace, "calendar-proxy-write-for" ),
)
@@ -887,25 +884,6 @@
else:
returnValue(customxml.DropBoxHomeURL(davxml.HRef(url)))
- elif name == "first-name":
- firstName = self.record.firstName
- if firstName:
- returnValue(customxml.FirstNameProperty(firstName))
- else:
- returnValue(None)
-
- elif name == "last-name":
- lastName = self.record.lastName
- if lastName:
- returnValue(customxml.LastNameProperty(lastName))
- else:
- returnValue(None)
-
- elif name == "email-address-set":
- returnValue(customxml.EmailAddressSet(
- *[customxml.EmailAddressProperty(addr) for addr in self.record.emailAddresses]
- ))
-
elif name == "calendar-proxy-read-for":
results = (yield self.proxyFor(False))
returnValue(customxml.CalendarProxyReadFor(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090415/024bc154/attachment.html>
More information about the calendarserver-changes
mailing list