[CalendarServer-changes] [5897] CalendarServer/branches/new-store

source_changes at macosforge.org source_changes at macosforge.org
Wed Jul 14 09:02:08 PDT 2010


Revision: 5897
          http://trac.macosforge.org/projects/calendarserver/changeset/5897
Author:   cdaboo at apple.com
Date:     2010-07-14 09:02:07 -0700 (Wed, 14 Jul 2010)
Log Message:
-----------
Make sure inline ATTACH properties don't generate dropboxIDs. Also move some methods to ical.py.

Modified Paths:
--------------
    CalendarServer/branches/new-store/twistedcaldav/ical.py
    CalendarServer/branches/new-store/txcaldav/calendarstore/file.py

Modified: CalendarServer/branches/new-store/twistedcaldav/ical.py
===================================================================
--- CalendarServer/branches/new-store/twistedcaldav/ical.py	2010-07-14 15:33:32 UTC (rev 5896)
+++ CalendarServer/branches/new-store/twistedcaldav/ical.py	2010-07-14 16:02:07 UTC (rev 5897)
@@ -1765,10 +1765,13 @@
         """
         Test for the existence of one or more properties in any component.
         
-        @param properties: property names to test for
-        @type properties: C{list} or C{tuple}
+        @param properties: property name(s) to test for
+        @type properties: C{list}, C{tuple} or C{str}
         """
 
+        if isinstance(properties, str):
+            properties = (properties,)
+            
         for property in properties:
             if self.hasProperty(property):
                 return True
@@ -1779,6 +1782,29 @@
 
         return False
 
+    def getFirstPropertyInAnyComponent(self, properties):
+        """
+        Get the first of any set of properties in any component.
+        
+        @param properties: property name(s) to test for
+        @type properties: C{list}, C{tuple} or C{str}
+        """
+
+        if isinstance(properties, str):
+            properties = (properties,)
+            
+        for property in properties:
+            props = tuple(self.properties(property))
+            if props:
+                return props[0]
+
+        for component in self.subcomponents():
+            prop = component.getFirstPropertyInAnyComponent(properties)
+            if prop:
+                return prop
+
+        return None
+
     def hasPropertyValueInAllComponents(self, property):
         """
         Test for the existence of a property with a specific value in any sub-component.

Modified: CalendarServer/branches/new-store/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/calendarstore/file.py	2010-07-14 15:33:32 UTC (rev 5896)
+++ CalendarServer/branches/new-store/txcaldav/calendarstore/file.py	2010-07-14 16:02:07 UTC (rev 5897)
@@ -356,38 +356,26 @@
             return None
 
 
-    def _allSubcomponents(self, component):
-        for subcomponent in component.subcomponents():
-            yield subcomponent
-            for deeper in self._allSubcomponents(subcomponent):
-                yield deeper
-
-
-    def _anyProperty(self, name):
-        component = self.component()
-        for subcomp in self._allSubcomponents(component):
-            dropboxProperty = subcomp.getProperty(name)
-            if dropboxProperty is not None:
-                return dropboxProperty.value()
-        return None
-
-
     def attendeesCanManageAttachments(self):
-        return bool(self._anyProperty("X-APPLE-DROPBOX"))
+        return self.component().hasPropertyInAnyComponent("X-APPLE-DROPBOX")
 
 
     def dropboxID(self):
         # FIXME: direct tests
-        dropboxProperty = self._anyProperty("X-APPLE-DROPBOX")
+        dropboxProperty = self.component().getFirstPropertyInAnyComponent("X-APPLE-DROPBOX")
         if dropboxProperty is not None:
-            componentDropboxID = dropboxProperty.split("/")[-1]
+            componentDropboxID = dropboxProperty.value().split("/")[-1]
             return componentDropboxID
-        attachProperty = self._anyProperty("ATTACH")
+        attachProperty = self.component().getFirstPropertyInAnyComponent("ATTACH")
         if attachProperty is not None:
-            # FIXME: more aggressive checking to see if this URI is really the
-            # 'right' URI.  Maybe needs to happen in the front end.
-            attachPath = attachProperty.split("/")[-2]
-            return attachPath
+            # Make sure the value type is URI
+            valueType = attachProperty.params().get("VALUE", ("TEXT",))
+            if valueType[0] == "URI": 
+                # FIXME: more aggressive checking to see if this URI is really the
+                # 'right' URI.  Maybe needs to happen in the front end.
+                attachPath = attachProperty.value().split("/")[-2]
+                return attachPath
+        
         return self.uid() + ".dropbox"
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100714/d13a4abd/attachment-0001.html>


More information about the calendarserver-changes mailing list