[CalendarServer-changes] [4928] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Jan 15 17:13:14 PST 2010


Revision: 4928
          http://trac.macosforge.org/projects/calendarserver/changeset/4928
Author:   wsanchez at apple.com
Date:     2010-01-15 17:13:10 -0800 (Fri, 15 Jan 2010)
Log Message:
-----------
More flushing out of store API

Modified Paths:
--------------
    CalendarServer/trunk/txcaldav/icalendarstore.py
    CalendarServer/trunk/txcarddav/iaddressbookstore.py

Modified: CalendarServer/trunk/txcaldav/icalendarstore.py
===================================================================
--- CalendarServer/trunk/txcaldav/icalendarstore.py	2010-01-15 06:05:50 UTC (rev 4927)
+++ CalendarServer/trunk/txcaldav/icalendarstore.py	2010-01-16 01:13:10 UTC (rev 4928)
@@ -24,10 +24,66 @@
     "ICalendarObject",
 ]
 
+from datetime import datetime, date, tzinfo
+
 from zope.interface import Interface #, Attribute
 
+from twext.ical import Component
 from txdav.idav import IPropertyStore
 
+#
+# Exceptions
+#
+
+class CalendarStoreError(RuntimeError):
+    """
+    Calendar store generic error.
+    """
+
+class AlreadyExistsError(CalendarStoreError):
+    """
+    Attempt to create an object that already exists.
+    """
+
+class CalendarAlreadyExistsError(AlreadyExistsError):
+    """
+    Calendar already exists.
+    """
+
+class CalendarObjectNameAlreadyExistsError(AlreadyExistsError):
+    """
+    A calendar object with the requested name already exists.
+    """
+
+class CalendarObjectUIDAlreadyExistsError(AlreadyExistsError):
+    """
+    A calendar object with the requested UID already exists.
+    """
+
+class NotFoundError(CalendarStoreError):
+    """
+    Requested data not found.
+    """
+
+class NoSuchCalendarError(NotFoundError):
+    """
+    The requested calendar does not exist.
+    """
+
+class NoSuchCalendarObjectError(NotFoundError):
+    """
+    The requested calendar object does not exist.
+    """
+
+class InvalidCalendarComponentError(CalendarStoreError):
+    """
+    Invalid calendar component.
+    """
+
+#
+# Interfaces
+#
+
 class ICalendarHome(Interface):
     """
     Calendar home
@@ -35,6 +91,7 @@
     def calendars(self):
         """
         Retrieve calendars contained in this calendar home.
+
         @return: an iterable of L{ICalendar}s.
         """
 
@@ -42,18 +99,36 @@
         """
         Retrieve the calendar with the given C{name} contained in this
         calendar home.
-        @return: an L{ICalendar}.
+
+        @param name: a string.
+        @return: an L{ICalendar} or C{None} if no such calendar
+            exists.
         """
 
     def createCalendarWithName(self, name):
         """
         Create a calendar with the given C{name} in this calendar
         home.
+
+        @param name: a string.
+        @raise CalendarAlreadyExistsError: if a calendar with the
+            given C{name} already exists.
         """
 
+    def removeCalendarWithName(self, name):
+        """
+        Remove the calendar with the given C{name} from this calendar
+        home.  If this calendar home owns the calendar, also remove
+        the calendar from all calendar homes.
+
+        @param name: a string.
+        @raise NoSuchCalendarObjectError: if no such calendar exists.
+        """
+
     def properties(self):
         """
         Retrieve the property store for this calendar home.
+
         @return: an L{IPropertyStore}.
         """
 
@@ -66,12 +141,14 @@
         Retrieve the calendar home for the owner of this calendar.
         Calendars may be shared from one (the owner's) calendar home
         to other (the sharee's) calendar homes.
+
         @return: an L{ICalendarHome}.
         """
 
     def calendarObjects(self):
         """
         Retrieve the calendar objects contained in this calendar.
+
         @return: an iterable of L{ICalendarObject}s.
         """
 
@@ -79,44 +156,93 @@
         """
         Retrieve the calendar object with the given C{name} contained
         in this calendar.
+
+        @param name: a string.
         @return: an L{ICalendarObject} or C{None} if no such calendar
-        object exists.
+            object exists.
         """
 
     def calendarObjectWithUID(self, uid):
         """
         Retrieve the calendar object with the given C{uid} contained
         in this calendar.
+
+        @param uid: a string.
         @return: an L{ICalendarObject} or C{None} if no such calendar
-        object exists.
+            object exists.
         """
 
+    def createCalendarObjectWithName(self, name, component):
+        """
+        Create a calendar component with the given C{name} in this
+        calendar from the given C{component}.
+
+        @param name: a string.
+        @param component: a C{VCALENDAR} L{Component}
+        @raise CalendarObjectNameAlreadyExistsError: if a calendar
+            object with the given C{name} already exists.
+        @raise CalendarObjectUIDAlreadyExistsError: if a calendar
+            object with the same UID as the given C{component} already
+            exists.
+        @raise InvalidCalendarComponentError: if the given
+            C{component} is not a valid C{VCALENDAR} L{Component} for
+            a calendar object.
+        """
+
+    def removeCalendarComponentWithName(self, name):
+        """
+        Remove the calendar component with the given C{name} from this
+        calendar.
+
+        @param name: a string.
+        @raise NoSuchCalendarObjectError: if no such calendar object
+            exists.
+        """
+
+    def removeCalendarComponentWithUID(self, uid):
+        """
+        Remove the calendar component with the given C{uid} from this
+        calendar.
+
+        @param uid: a string.
+        @raise NoSuchCalendarObjectError: if the calendar object does
+            not exist.
+        """
+
     def syncToken(self):
         """
         Retrieve the current sync token for this calendar.
+
         @return: a string containing a sync token.
         """
 
-#    def calendarObjectsInTimeRange(self, start, end, timeZone):
-#        """
-#        Retrieve all calendar objects in this calendar which have
-#        instances that occur within the time range that begins at
-#        C{start} and ends at C{end}.
-#        @return: an iterable of L{ICalendarObject}s.
-#        """
+    def calendarObjectsInTimeRange(self, start, end, timeZone):
+        """
+        Retrieve all calendar objects in this calendar which have
+        instances that occur within the time range that begins at
+        C{start} and ends at C{end}.
 
+        @param start: a L{datetime} or L{date}.
+        @param end: a L{datetime} or L{date}.
+        @param timeZone: a L{tzinfo}.
+        @return: an iterable of L{ICalendarObject}s.
+        """
+
     def calendarObjectsSinceToken(self, token):
         """
         Retrieve all calendar objects in this calendar that have
         changed since the given C{token} was last valid.
+
+        @param token: a sync token.
         @return: a 3-tuple containing an iterable of
-        L{ICalendarObject}s that have changed, an iterable of uids
-        that have been removed, and the current sync token.
+            L{ICalendarObject}s that have changed, an iterable of uids
+            that have been removed, and the current sync token.
         """
 
     def properties(self):
         """
         Retrieve the property store for this calendar.
+
         @return: an L{IPropertyStore}.
         """
 
@@ -124,16 +250,37 @@
     """
     Calendar object (event, to-do, etc.).
     """
+    def setComponent(self, component):
+        """
+        Rewrite this calendar object to match the given C{component}.
+        C{component} must have the same UID and be of the same
+        component type as this calendar object.
+
+        @param component: a C{VCALENDAR} L{Component}.
+        @raise InvalidCalendarComponentError: if the given
+            C{component} is not a valid C{VCALENDAR} L{Component} for
+            a calendar object.
+        """
+
+    def component(self):
+        """
+        Retrieve the calendar component for this calendar object.
+
+        @return: a C{VCALENDAR} L{Component}.
+        """
+
     def iCalendarText(self):
         """
         Retrieve the iCalendar text data for this calendar object.
+
         @return: a string containing iCalendar data for a single
-        calendar object.
+            calendar object.
         """
 
     def uid(self):
         """
         Retrieve the UID for this calendar object.
+
         @return: a string containing a UID.
         """
 
@@ -141,18 +288,22 @@
         """
         Retrieve the iCalendar component type for the main component
         in this calendar object.
+
         @return: a string containing the component type.
         """
 
     def organizer(self):
         # FIXME: Ideally should return a URI object
         """
-        Retrieve the organizer for this calendar object.
-        @return: a calendar user address.
+        Retrieve the organizer's calendar user address for this
+        calendar object.
+
+        @return: a URI string.
         """
 
     def properties(self):
         """
         Retrieve the property store for this calendar object.
+
         @return: an L{IPropertyStore}.
         """

Modified: CalendarServer/trunk/txcarddav/iaddressbookstore.py
===================================================================
--- CalendarServer/trunk/txcarddav/iaddressbookstore.py	2010-01-15 06:05:50 UTC (rev 4927)
+++ CalendarServer/trunk/txcarddav/iaddressbookstore.py	2010-01-16 01:13:10 UTC (rev 4928)
@@ -23,8 +23,62 @@
 
 from zope.interface import Interface #, Attribute
 
+from twext.ical import Component
 from txdav.idav import IPropertyStore
 
+#
+# Exceptions
+#
+
+class AddressBookStoreError(RuntimeError):
+    """
+    Address book store generic error.
+    """
+
+class AlreadyExistsError(AddressBookStoreError):
+    """
+    Attempt to create an object that already exists.
+    """
+
+class AddressBookAlreadyExistsError(AlreadyExistsError):
+    """
+    Address book already exists.
+    """
+
+class ContactCardNameAlreadyExistsError(AlreadyExistsError):
+    """
+    A contact card with the requested name already exists.
+    """
+
+class ContactCardUIDAlreadyExistsError(AlreadyExistsError):
+    """
+    A contact card with the requested UID already exists.
+    """
+
+class NotFoundError(AddressBookStoreError):
+    """
+    Requested data not found.
+    """
+
+class NoSuchAddressBookError(NotFoundError):
+    """
+    The requested address book does not exist.
+    """
+
+class NoSuchContactCardError(NotFoundError):
+    """
+    The requested contact card does not exist.
+    """
+
+class InvalidCardComponentError(AddressBookStoreError):
+    """
+    Invalid card component.
+    """
+
+#
+# Interfaces
+#
+
 class IAddressBookHome(Interface):
     """
     Address book home
@@ -32,6 +86,7 @@
     def addressBooks(self):
         """
         Retrieve address books contained in this address book home.
+
         @return: an iterable of L{IAddressBook}s.
         """
 
@@ -39,19 +94,26 @@
         """
         Retrieve the address book with the given C{name} contained in
         this address book home.
+
+        @param name: a string.
         @return: an L{IAddressBook} or C{None} if no such address book
-        exists.
+            exists.
         """
 
     def createAddressBookWithName(self, name):
         """
         Create an address book with the given C{name} in this address
         book home.
+
+        @param name: a string.
+        @raise AddressBookAlreadyExistsError: if an address book
+            with the given C{name} already exists.
         """
 
     def properties(self):
         """
         Retrieve the property store for this address book home.
+
         @return: an L{IPropertyStore}.
         """
 
@@ -62,6 +124,7 @@
     def contactCards(self):
         """
         Retrieve the contact cards contains in this address book.
+
         @return: an iterable of L{IContactCard}s.
         """
 
@@ -69,36 +132,59 @@
         """
         Retrieve the contact card with the given C{name} in this
         address book.
+
+        @param name: a string.
         @return: an L{IContactCard} or C{None} is no such contact card
-        exists.
+            exists.
         """
 
     def contactCardWithUID(self, uid):
         """
         Retrieve the contact card with the given C{uid} in this
         address book.
+
+        @param uid: a string.
         @return: an L{IContactCard} or C{None} is no such contact card
-        exists.
+            exists.
         """
 
+    def createContactCardWithName(self, name):
+        """
+        Create a contact card with the given C{name} in this address
+        book from the given C{component}.
+
+        @param name: a string.
+        @param component: a C{VCARD} L{Component}.
+        @raise ContactCardNameAlreadyExistsError: if a contact card
+            with the given C{name} already exists.
+        @raise ContactCardUIDAlreadyExistsError: if a contact card
+            with the same UID as the given C{component} already
+            exists.
+        @raise InvalidCardComponentError: if the given C{component} is
+            not a valid C{VCARD} L{Component} for a contact card.
+        """
+
     def syncToken(self):
         """
         Retrieve the current sync token for this address book.
-        @return: a string containing a sync token.
+
+        @return: a sync token.
         """
 
     def contactCardsSinceToken(self, token):
         """
         Retrieve all contact cards in this address book that have
         changed since the given C{token} was last valid.
+
         @return: a 3-tuple containing an iterable of L{IContactCard}s
-        that have changed, an iterable of uids that have been removed,
-        and the current sync token.
+            that have changed, an iterable of uids that have been
+            removed, and the current sync token.
         """
 
     def properties(self):
         """
         Retrieve the property store for this address book.
+
         @return: an L{IPropertyStore}.
         """
 
@@ -106,21 +192,41 @@
     """
     Contact card
     """
+    def setComponent(self):
+        """
+        Rewrite this contact card to match the given C{component}.
+        C{component} must have the same UID as this contact card.
+
+        @param component: a C{VCARD} L{Component}.
+        @raise InvalidCardComponentError: if the given C{component} is
+            not a valid C{VCARD} L{Component} for a contact card.
+        """
+
+    def component(self):
+        """
+        Retrieve the contact component for this contact card.
+
+        @return: a C{VCARD} L{Component}.
+        """
+
     def vCardText(self):
         """
         Retrieve the vCard text data for this contact card.
+
         @return: a string containing vCard data for a single vCard
-        contact.
+            contact.
         """
 
     def uid(self):
         """
         Retrieve the UID for this contact card.
+
         @return: a string containing a UID.
         """
 
     def properties(self):
         """
         Retrieve the property store for this contact card.
+
         @return: an L{IPropertyStore}.
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100115/e25d024b/attachment-0001.html>


More information about the calendarserver-changes mailing list