[CalendarServer-changes] [6138] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 19 15:26:32 PDT 2010


Revision: 6138
          http://trac.macosforge.org/projects/calendarserver/changeset/6138
Author:   glyph at apple.com
Date:     2010-08-19 15:26:32 -0700 (Thu, 19 Aug 2010)
Log Message:
-----------
expand (and hopefully complete) breadcrumbs api to allow getting back to the notifications collection from a notification.  also fixes 500 errors from CalDAV/sharing-invites.xml.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/storebridge.py
    CalendarServer/trunk/txcaldav/calendarstore/postgres.py
    CalendarServer/trunk/txcaldav/calendarstore/test/common.py
    CalendarServer/trunk/txdav/common/datastore/file.py
    CalendarServer/trunk/txdav/common/inotifications.py

Modified: CalendarServer/trunk/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/storebridge.py	2010-08-19 21:20:01 UTC (rev 6137)
+++ CalendarServer/trunk/twistedcaldav/storebridge.py	2010-08-19 22:26:32 UTC (rev 6138)
@@ -386,7 +386,7 @@
 
 
     def resourceType(self,):
-        return davxml.ResourceType.dropboxhome
+        return davxml.ResourceType.dropboxhome #@UndefinedVariable
 
 
     def listChildren(self):
@@ -431,7 +431,7 @@
 
 
     def resourceType(self):
-        return davxml.ResourceType.dropbox
+        return davxml.ResourceType.dropbox #@UndefinedVariable
 
 
     def getChild(self, name):
@@ -1991,7 +1991,7 @@
 
         try:
 
-            storeNotifications = self._newStoreObject._notificationCollection
+            storeNotifications = self._newStoreObject.notificationCollection()
 
             # Do delete
 

Modified: CalendarServer/trunk/txcaldav/calendarstore/postgres.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-19 21:20:01 UTC (rev 6137)
+++ CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-19 22:26:32 UTC (rev 6138)
@@ -79,7 +79,7 @@
 from twistedcaldav.instance import InvalidOverriddenInstanceError
 from twistedcaldav.memcachepool import CachePoolUserMixIn
 from twistedcaldav.notifications import NotificationRecord
-from twistedcaldav.query import calendarqueryfilter, calendarquery,\
+from twistedcaldav.query import calendarqueryfilter, calendarquery, \
     addressbookquery
 from twistedcaldav.query.sqlgenerator import sqlgenerator
 from twistedcaldav.sharing import Invite
@@ -1769,9 +1769,14 @@
         self._resourceID = resourceID
 
 
+    def notificationCollection(self):
+        return self._home
+
+
     def name(self):
         return self.uid() + ".xml"
 
+
     def contentType(self):
         """
         The content type of NotificationObjects is text/xml.
@@ -1872,7 +1877,7 @@
 
 
 
-class PostgresNotificationsCollection(object):
+class PostgresNotificationCollection(object):
 
     implements(INotificationCollection)
 
@@ -2074,7 +2079,7 @@
             self.execSQL(
                 "insert into NOTIFICATION_HOME (RESOURCE_ID, OWNER_UID) "
                 "values (%s, %s)", [resourceID, uid])
-        return PostgresNotificationsCollection(self, uid, resourceID)
+        return PostgresNotificationCollection(self, uid, resourceID)
 
 
     def abort(self):
@@ -2389,7 +2394,7 @@
             qualifiers = addressbookquery.sqladdressbookquery(filter)
         else:
             qualifiers = None
-            
+
         return qualifiers is not None
 
     def search(self, filter):
@@ -2401,7 +2406,7 @@
             C{name} is the resource name, C{uid} is the resource UID, and
             C{type} is the resource iCalendar component type.x
         """
-        
+
         # Make sure we have a proper Filter element and get the partial SQL statement to use.
         if isinstance(filter, carddavxml.Filter):
             qualifiers = addressbookquery.sqladdressbookquery(filter, self.addressbook._resourceID, generator=postgresqladbkgenerator)
@@ -2418,7 +2423,7 @@
                 "select RESOURCE_NAME, VCARD_UID from ADDRESSBOOK_OBJECT where ADDRESSBOOK_RESOURCE_ID = %s",
                 [self.addressbook._resourceID, ],
             )
-            
+
         for row in rowiter:
             yield row
 

Modified: CalendarServer/trunk/txcaldav/calendarstore/test/common.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/common.py	2010-08-19 21:20:01 UTC (rev 6137)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/common.py	2010-08-19 22:26:32 UTC (rev 6138)
@@ -334,6 +334,17 @@
         self.assertIsInstance(notification.modified(), int)
 
 
+    def test_notificationObjectParent(self):
+        """
+        L{INotificationObject.notificationCollection} returns the
+        L{INotificationCollection} that the object was retrieved from.
+        """
+        txn = self.transactionUnderTest()
+        collection = txn.notificationsWithUID("home1")
+        notification = self.notificationUnderTest()
+        self.assertIdentical(collection, notification.notificationCollection())
+
+
     def test_notifierID(self):
         home = self.homeUnderTest()
         self.assertEquals(home.notifierID(), "home1")
@@ -341,6 +352,7 @@
         self.assertEquals(calendar.notifierID(), "home1")
         self.assertEquals(calendar.notifierID(label="collection"), "home1/calendar_1")
 
+
     def test_calendarHomeWithUID_exists(self):
         """
         Finding an existing calendar home by UID results in an object that
@@ -422,8 +434,8 @@
                 calendarProperties[
                     PropertyName.fromString(davxml.ResourceType.sname())
                 ],
-                davxml.ResourceType.calendar
-            ) #@UndefinedVariable
+                davxml.ResourceType.calendar #@UndefinedVariable
+            )
         checkProperties()
 
         self.commit()

Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py	2010-08-19 21:20:01 UTC (rev 6137)
+++ CalendarServer/trunk/txdav/common/datastore/file.py	2010-08-19 22:26:32 UTC (rev 6138)
@@ -864,10 +864,13 @@
     implements(INotificationObject)
 
     def __init__(self, name, notifications):
-
         super(NotificationObject, self).__init__(name, notifications)
 
 
+    def notificationCollection(self):
+        return self._parentCollection
+
+
     def modified(self):
         if not self._path.exists():
             from twisted.internet import reactor
@@ -875,15 +878,11 @@
         return super(NotificationObject, self).modified()
 
 
-    @property
-    def _notificationCollection(self):
-        return self._parentCollection
-
     @writeOperation
     def setData(self, uid, xmltype, xmldata):
 
         rname = uid + ".xml"
-        self._notificationCollection.retrieveOldIndex().addOrUpdateRecord(
+        self._parentCollection.retrieveOldIndex().addOrUpdateRecord(
             NotificationRecord(uid, rname, xmltype.name)
         )
 

Modified: CalendarServer/trunk/txdav/common/inotifications.py
===================================================================
--- CalendarServer/trunk/txdav/common/inotifications.py	2010-08-19 21:20:01 UTC (rev 6137)
+++ CalendarServer/trunk/txdav/common/inotifications.py	2010-08-19 22:26:32 UTC (rev 6138)
@@ -177,3 +177,13 @@
 
         @return: a string containing a UID.
         """
+
+
+    def notificationCollection():
+        """
+        @return: the parent L{INotificationCollection} which this
+            L{INotificationObject} was retrieved from.
+
+        @rtype: L{INotificationCollection}
+        """
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100819/09369d0b/attachment-0001.html>


More information about the calendarserver-changes mailing list