def readProperty(self, property, request): if type(property) is tuple: qname = property else: qname = property.qname() if qname == (caldav_namespace, "calendar-free-busy-set"): # Always return at least an empty list if not self.hasDeadProperty(property): top = self.parent.url() values = [] for cal in self.parent._newStoreHome.calendars(): prop = cal.properties().get(PropertyName.fromString(ScheduleCalendarTransp.sname())) if prop == ScheduleCalendarTransp(Opaque()): values.append(HRef(joinURL(top, cal.name()))) returnValue(CalendarFreeBusySet(*values)) elif qname == (caldav_namespace, "schedule-default-calendar-URL"): # Must have a valid default try: defaultCalendarProperty = self.readDeadProperty(property) except HTTPError: defaultCalendarProperty = None if defaultCalendarProperty and len(defaultCalendarProperty.children) == 1: defaultCalendar = str(defaultCalendarProperty.children[0]) cal = (yield request.locateResource(str(defaultCalendar))) if cal is not None and cal.exists() and isCalendarCollectionResource(cal): returnValue(defaultCalendarProperty) # Default is not valid - we have to try to pick one defaultCalendarProperty = (yield self.pickNewDefaultCalendar(request)) returnValue(defaultCalendarProperty) result = (yield super(ScheduleInboxResource, self).readProperty(property, request)) returnValue(result)
def _keys_uid(self, uid): rows = self._txn.execSQL( "select NAME from RESOURCE_PROPERTY where " "VIEWER_UID = %s and RESOURCE_ID = %s", [uid, self._resourceID] ) for row in rows: yield PropertyName.fromString(row[0])
def checkProperties(): addressbookProperties = (yield home.addressbookWithName(name)).properties() addressbookType = ResourceType.addressbook #@UndefinedVariable self.assertEquals( addressbookProperties[ PropertyName.fromString(ResourceType.sname()) ], addressbookType )
def readProperty(self, property, request): if type(property) is tuple: qname = property else: qname = property.qname() if qname == caldavxml.CalendarFreeBusySet.qname(): # Always return at least an empty list if not self.hasDeadProperty(property): top = self.parent.url() values = [] for cal in (yield self.parent._newStoreHome.calendars()): prop = cal.properties().get(PropertyName.fromString(ScheduleCalendarTransp.sname())) if prop == ScheduleCalendarTransp(Opaque()): values.append(HRef(joinURL(top, cal.name()))) returnValue(CalendarFreeBusySet(*values)) elif qname in (caldavxml.ScheduleDefaultCalendarURL.qname(), customxml.ScheduleDefaultTasksURL.qname()): result = (yield self.readDefaultCalendarProperty(request, qname)) returnValue(result) result = (yield super(ScheduleInboxResource, self).readProperty(property, request)) returnValue(result)
def _keys_uid(self, uid): for cachedKey, cachedUID in self._cached.keys(): if cachedUID == uid: yield PropertyName.fromString(cachedKey)
def test_fromString(self): name = PropertyName.fromString("{http://calendarserver.org/}bleargh") self.assertEquals(name.namespace, "http://calendarserver.org/") self.assertEquals(name.name, "bleargh")