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

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 17 13:46:16 PDT 2011


Revision: 8208
          http://trac.macosforge.org/projects/calendarserver/changeset/8208
Author:   sagen at apple.com
Date:     2011-10-17 13:46:16 -0700 (Mon, 17 Oct 2011)
Log Message:
-----------
Fix problem where directory gateway couldn't handle generating vcards from records with multiple phone numbers or email addresses.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/ical.py
    CalendarServer/trunk/twistedcaldav/vcard.py

Added Paths:
-----------
    CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectorybacker.py

Added: CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectorybacker.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectorybacker.py	                        (rev 0)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_opendirectorybacker.py	2011-10-17 20:46:16 UTC (rev 8208)
@@ -0,0 +1,37 @@
+##
+# Copyright (c) 2011 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from twistedcaldav.directory.opendirectorybacker import VCardRecord
+from twistedcaldav.test.util import TestCase
+
+class VCardRecordTestCase(TestCase):
+
+
+    def test_multiplePhoneNumbersAndEmailAddresses(self):
+        attributes={u'dsAttrTypeStandard:AppleMetaRecordName': ['uid=odtestamanda,cn=users,dc=dalek,dc=example,dc=com'], u'dsAttrTypeStandard:ModificationTimestamp': '20111017170937Z', u'dsAttrTypeStandard:PhoneNumber': ['408 555-1212', '415 555-1212'], u'dsAttrTypeStandard:RecordType': ['dsRecTypeStandard:Users'], u'dsAttrTypeStandard:AppleMetaNodeLocation': ['/LDAPv3/127.0.0.1'], u'dsAttrTypeStandard:RecordName': ['odtestamanda'], u'dsAttrTypeStandard:FirstName': 'Amanda', u'dsAttrTypeStandard:GeneratedUID': '9DC04A70-E6DD-11DF-9492-0800200C9A66', u'dsAttrTypeStandard:LastName': 'Test', u'dsAttrTypeStandard:CreationTimestamp': '20110927182945Z', u'dsAttrTypeStandard:EMailAddress': ['amanda at example.com', 'second at example.com'], u'dsAttrTypeStandard:RealName': 'Amanda Test'}
+        vcardRecord = VCardRecord(StubService(), attributes)
+        vcard = vcardRecord.vCard()
+        properties = set([prop.value() for prop in vcard.properties("TEL")])
+        self.assertEquals(properties, set(["408 555-1212", "415 555-1212"]))
+        properties = set([prop.value() for prop in vcard.properties("EMAIL")])
+        self.assertEquals(properties, set(["amanda at example.com", "second at example.com"]))
+
+
+class StubService(object):
+    addDSAttrXProperties = False
+    directoryBackedAddressBook = None
+    appleInternalServer = False
+    realmName = "testing"

Modified: CalendarServer/trunk/twistedcaldav/ical.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/ical.py	2011-10-15 15:14:28 UTC (rev 8207)
+++ CalendarServer/trunk/twistedcaldav/ical.py	2011-10-17 20:46:16 UTC (rev 8208)
@@ -244,14 +244,16 @@
         self._pycalendar.setAttributes({})
 
     def removeParameterValue(self, paramname, paramvalue):
-        
-        for attr in tuple(self._pycalendar.getAttributes()):
-            if attr.getName() == paramname:
-                for value in attr.getValues():
-                    if value == paramvalue:
-                        if not attr.removeValue(value):
-                            self._pycalendar.removeAttributes(paramname)
 
+        paramname = paramname.upper()
+        for attrName in self.parameterNames():
+            if attrName.upper() == paramname:
+                for attr in tuple(self._pyalendar.getAttributes()[attrName]):
+                    for value in attr.getValues():
+                        if value == paramvalue:
+                            if not attr.removeValue(value):
+                                self._pyalendar.removeAttributes(paramname)
+
     def containsTimeRange(self, start, end, defaulttz=None):
         """
         Determines whether this property contains a date/date-time within the specified

Modified: CalendarServer/trunk/twistedcaldav/vcard.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/vcard.py	2011-10-15 15:14:28 UTC (rev 8207)
+++ CalendarServer/trunk/twistedcaldav/vcard.py	2011-10-17 20:46:16 UTC (rev 8208)
@@ -164,14 +164,16 @@
     def removeParameterValue(self, paramname, paramvalue):
         
         paramname = paramname.upper()
-        for attr in tuple(self._pycard.getAttributes()):
-            if attr.getName().upper() == paramname:
-                for value in attr.getValues():
-                    if value == paramvalue:
-                        if not attr.removeValue(value):
-                            self._pycard.removeAttributes(paramname)
+        for attrName in self.parameterNames():
+            if attrName.upper() == paramname:
+                for attr in tuple(self._pycard.getAttributes()[attrName]):
+                    for value in attr.getValues():
+                        if value == paramvalue:
+                            if not attr.removeValue(value):
+                                self._pycard.removeAttributes(paramname)
 
 
+
 class Component (object):
     """
     X{vCard} component.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111017/c28f3ebf/attachment.html>


More information about the calendarserver-changes mailing list