[CalendarServer-changes] [8977] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Wed Apr 4 10:19:48 PDT 2012


Revision: 8977
          http://trac.macosforge.org/projects/calendarserver/changeset/8977
Author:   sagen at apple.com
Date:     2012-04-04 10:19:48 -0700 (Wed, 04 Apr 2012)
Log Message:
-----------
Set parent on Property when instantiating them via properties()

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/test/test_icalendar.py

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2012-04-04 01:17:47 UTC (rev 8976)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2012-04-04 17:19:48 UTC (rev 8977)
@@ -148,7 +148,7 @@
     """
     iCalendar Property
     """
-    def __init__(self, name, value, params={}, **kwargs):
+    def __init__(self, name, value, params={}, parent=None, **kwargs):
         """
         @param name: the property's name
         @param value: the property's value
@@ -171,6 +171,8 @@
             for attrname, attrvalue in params.items():
                 self._pycalendar.addAttribute(PyCalendarAttribute(attrname, attrvalue))
 
+        self._parent = parent
+
     def __str__(self): return str(self._pycalendar)
     def __repr__(self): return "<%s: %r: %r>" % (self.__class__.__name__, self.name(), self.value())
 
@@ -200,6 +202,7 @@
         Duplicate this object and all its contents.
         @return: the duplicated calendar.
         """
+        # FIXME: does the parent need to be set in this case?
         return Property(None, None, None, pycalendar=self._pycalendar.duplicate())
 
     def name(self): return self._pycalendar.getName()
@@ -655,7 +658,7 @@
             properties = self._pycalendar.getProperties(name)
 
         return (
-            Property(None, None, None, pycalendar=p)
+            Property(None, None, None, parent=self, pycalendar=p)
             for p in properties
         )
 

Modified: CalendarServer/trunk/twistedcaldav/test/test_icalendar.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2012-04-04 01:17:47 UTC (rev 8976)
+++ CalendarServer/trunk/twistedcaldav/test/test_icalendar.py	2012-04-04 17:19:48 UTC (rev 8977)
@@ -6113,6 +6113,11 @@
         self.assertEquals(component._cachedCopy, None) # cache is invalidated
 
         str(component) # to serialize and cache
+        self.assertNotEquals(component._cachedCopy, None)
+        retrieved = component.getProperty("PRODID")
+        self.assertEquals(retrieved._parent, component)
+
+        str(component) # to serialize and cache
         component.removeProperty(prop)
         self.assertEquals(prop._parent, None)
         self.assertEquals(component._cachedCopy, None) # cache is invalidated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120404/29f213b7/attachment.html>


More information about the calendarserver-changes mailing list