[CalendarServer-changes] [6098] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue Aug 17 17:06:05 PDT 2010


Revision: 6098
          http://trac.macosforge.org/projects/calendarserver/changeset/6098
Author:   sagen at apple.com
Date:     2010-08-17 17:06:04 -0700 (Tue, 17 Aug 2010)
Log Message:
-----------
Sets the notificationtype DAV property on notification objects

Modified Paths:
--------------
    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/txcaldav/calendarstore/postgres.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-17 23:25:34 UTC (rev 6097)
+++ CalendarServer/trunk/txcaldav/calendarstore/postgres.py	2010-08-18 00:06:04 UTC (rev 6098)
@@ -1297,14 +1297,20 @@
     def name(self):
         return self.uid() + ".xml"
 
+    def contentType(self):
+        """
+        The content type of NotificationObjects is text/xml.
+        """
+        return MimeType.fromString("text/xml")
 
+
     @property
     def _txn(self):
         return self._home._txn
 
 
     def setData(self, uid, xmltype, xmldata):
-        self.properties()[PropertyName(*NotificationType.qname())] = NotificationType(xmltype)
+        self.properties()[PropertyName.fromElement(NotificationType)] = NotificationType(xmltype)
         return self._txn.execSQL(
             """
             update NOTIFICATION set NOTIFICATION_UID = %s, XML_TYPE = %s,
@@ -1348,6 +1354,8 @@
     def created(self):
         return None
 
+    def size(self):
+        return len(self.xmldata())
 
 
 class PostgresLegacyNotificationsEmulator(object):
@@ -1439,12 +1447,12 @@
 
 
     def writeNotificationObject(self, uid, xmltype, xmldata):
-        xmltype = PropertyName.fromElement(xmltype).toString()
+        xmltypeString = xmltype.toxml()
         self._txn.execSQL(
             "insert into NOTIFICATION (NOTIFICATION_HOME_RESOURCE_ID, NOTIFICATION_UID, XML_TYPE, XML_DATA) "
-            "values (%s, %s, %s, %s)", [self._resourceID, uid, xmltype, xmldata])
+            "values (%s, %s, %s, %s)", [self._resourceID, uid, xmltypeString, xmldata])
         notificationObject = self.notificationObjectWithUID(uid)
-        notificationObject.properties()[PropertyName(*NotificationType.qname())] = NotificationType(xmltype)
+        notificationObject.properties()[PropertyName.fromElement(NotificationType)] = NotificationType(xmltype)
 
     def removeNotificationObjectWithName(self, name):
         self.removeNotificationObjectWithUID(self._nameToUID(name))

Modified: CalendarServer/trunk/txcaldav/calendarstore/test/common.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/common.py	2010-08-17 23:25:34 UTC (rev 6097)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/common.py	2010-08-18 00:06:04 UTC (rev 6098)
@@ -35,6 +35,7 @@
 from txdav.common.icommondatastore import NoSuchHomeChildError
 from txdav.common.icommondatastore import NoSuchObjectResourceError
 from txdav.common.icommondatastore import ObjectResourceNameAlreadyExistsError
+from txdav.common.inotifications import INotificationObject
 
 from txcaldav.icalendarstore import (
     ICalendarObject, ICalendarHome,
@@ -47,6 +48,7 @@
 from twext.python.vcomponent import VComponent
 
 from twistedcaldav.notify import Notifier
+from twistedcaldav.customxml import InviteNotification
 
 storePath = FilePath(__file__).parent().child("calendar_store")
 
@@ -302,7 +304,16 @@
         """
         self.assertProvides(ICalendarObject, self.calendarObjectUnderTest())
 
+    def test_notificationObjectProvides(self):
+        txn = self.transactionUnderTest()
+        notifications = txn.notificationsWithUID("home1")
+        inviteNotification = InviteNotification()
+        notifications.writeNotificationObject("abc", inviteNotification,
+            inviteNotification.toxml())
+        notificationObject = notifications.notificationObjectWithUID("abc")
+        self.assertProvides(INotificationObject, notificationObject)
 
+
     def test_notifierID(self):
         home = self.homeUnderTest()
         self.assertEquals(home.notifierID(), "home1")

Modified: CalendarServer/trunk/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/file.py	2010-08-17 23:25:34 UTC (rev 6097)
+++ CalendarServer/trunk/txdav/common/datastore/file.py	2010-08-18 00:06:04 UTC (rev 6098)
@@ -907,8 +907,9 @@
 
         props = self.properties()
         props[PropertyName(*GETContentType.qname())] = GETContentType.fromString(generateContentType(MimeType("text", "xml", params={"charset":"utf-8"})))
-        props[PropertyName(*NotificationType.qname())] = NotificationType(xmltype)
+        props[PropertyName.fromElement(NotificationType)] = NotificationType(xmltype)
 
+
         # FIXME: the property store's flush() method may already have been
         # added to the transaction, but we need to add it again to make sure it
         # happens _after_ the new file has been written.  we may end up doing

Modified: CalendarServer/trunk/txdav/common/inotifications.py
===================================================================
--- CalendarServer/trunk/txdav/common/inotifications.py	2010-08-17 23:25:34 UTC (rev 6097)
+++ CalendarServer/trunk/txdav/common/inotifications.py	2010-08-18 00:06:04 UTC (rev 6098)
@@ -19,6 +19,7 @@
 """
 
 from zope.interface.interface import Interface
+from txdav.idav import IDataStoreResource
 
 
 __all__ = [
@@ -144,7 +145,7 @@
         """
 
 
-class INotificationObject(Interface):
+class INotificationObject(IDataStoreResource):
     """
     Notification object
 
@@ -176,10 +177,3 @@
 
         @return: a string containing a UID.
         """
-
-    def properties():
-        """
-        Retrieve the property store for this notification object.
-
-        @return: an L{IPropertyStore}.
-        """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100817/e07f53ff/attachment.html>


More information about the calendarserver-changes mailing list