[CalendarServer-changes] [13154] CalendarServer/branches/users/sagen/move2who-4

source_changes at macosforge.org source_changes at macosforge.org
Fri Apr 4 09:31:48 PDT 2014


Revision: 13154
          http://trac.calendarserver.org//changeset/13154
Author:   sagen at apple.com
Date:     2014-04-04 09:31:48 -0700 (Fri, 04 Apr 2014)
Log Message:
-----------
merge the two normalizationLookup implementations

Modified Paths:
--------------
    CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py
    CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py
    CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py

Modified: CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py	2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/calendarserver/tools/calverify.py	2014-04-04 16:31:48 UTC (rev 13154)
@@ -47,40 +47,38 @@
 import traceback
 import uuid
 
-from pycalendar.icalendar import definitions
-from pycalendar.icalendar.calendar import Calendar
+from calendarserver.tools import tables
+from calendarserver.tools.cmdline import utilityMain, WorkerService
 from pycalendar.datetime import DateTime
 from pycalendar.exceptions import ErrorBase
+from pycalendar.icalendar import definitions
+from pycalendar.icalendar.calendar import Calendar
 from pycalendar.period import Period
 from pycalendar.timezone import Timezone
-
+from twext.enterprise.dal.syntax import Select, Parameter, Count
+from twext.python.log import Logger
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.python import usage
 from twisted.python.usage import Options
-
-from twext.python.log import Logger
-from twext.enterprise.dal.syntax import Select, Parameter, Count
-
 from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
 from twistedcaldav.dateops import pyCalendarTodatetime
-from twistedcaldav.ical import Component, ignoredComponents, \
+from twistedcaldav.ical import (
+    Component, ignoredComponents,
     InvalidICalendarDataError, Property, PERUSER_COMPONENT
-from txdav.caldav.datastore.scheduling.itip import iTipGenerator
+)
 from twistedcaldav.stdconfig import DEFAULT_CONFIG_FILE
-from twistedcaldav.util import normalizationLookup
-
-from txdav.caldav.icalendarstore import ComponentUpdateState
 from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
 from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
+from txdav.caldav.datastore.scheduling.itip import iTipGenerator
 from txdav.caldav.datastore.sql import CalendarStoreFeatures
+from txdav.caldav.datastore.util import normalizationLookup
+from txdav.caldav.icalendarstore import ComponentUpdateState
 from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
 from txdav.common.icommondatastore import InternalDataStoreError
 from txdav.who.idirectory import (
     RecordType as CalRecordType, AutoScheduleMode
 )
-from calendarserver.tools.cmdline import utilityMain, WorkerService
 
-from calendarserver.tools import tables
 
 log = Logger()
 

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml	2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/directory/test/accounts.xml	2014-04-04 16:31:48 UTC (rev 13154)
@@ -285,17 +285,6 @@
     <member-uid>__cdaboo1__</member-uid>
   </record>
 
-  <!-- Repeat is not (yet?) supported in twext.who.xml
-  <user repeat="100">
-    <short-name>user%02d</short-name>
-    <uid>user%02d</uid>
-    <password>%02duser</password>
-    <full-name>~35 User %02d</full-name>
-    <first-name>~5</first-name>
-    <last-name>~9 User %02d</last-name>
-    <email>~10 at example.com</email>
-  </user>
-  -->
 
   <record type="group">
     <short-name>managers</short-name>

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py	2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/resource.py	2014-04-04 16:31:48 UTC (rev 13154)
@@ -77,7 +77,7 @@
 from twistedcaldav.linkresource import LinkResource
 from calendarserver.push.notifier import getPubSubAPSConfiguration
 from twistedcaldav.sharing import SharedResourceMixin, SharedHomeMixin
-from twistedcaldav.util import normalizationLookup
+from txdav.caldav.datastore.util import normalizationLookup
 from twistedcaldav.vcard import Component as vComponent
 
 from txdav.common.icommondatastore import InternalDataStoreError, \
@@ -1064,7 +1064,6 @@
         returnValue(PerUserDataFilter(accessUID).filter(caldata))
 
 
-    # MOVE2WHO returns Deferred
     def iCalendarAddressDoNormalization(self, ical):
         """
         Normalize calendar user addresses in the supplied iCalendar object into their
@@ -1072,9 +1071,12 @@
 
         @param ical: calendar object to normalize.
         @type ical: L{Component}
+        @return: L{Deferred}
         """
-        return ical.normalizeCalendarUserAddresses(normalizationLookup,
-            self.principalForCalendarUserAddress)
+        return ical.normalizeCalendarUserAddresses(
+            normalizationLookup,
+            self.record.service.recordWithCalendarUserAddress
+        )
 
 
     @inlineCallbacks

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py	2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/upgrade.py	2014-04-04 16:31:48 UTC (rev 13154)
@@ -43,7 +43,7 @@
 from txdav.caldav.datastore.scheduling.cuaddress import LocalCalendarUser
 from txdav.caldav.datastore.scheduling.imip.mailgateway import MailGatewayTokensDatabase
 from txdav.caldav.datastore.scheduling.scheduler import DirectScheduler
-from twistedcaldav.util import normalizationLookup
+from txdav.caldav.datastore.util import normalizationLookup
 
 from twisted.internet.defer import (
     inlineCallbacks, succeed, returnValue

Modified: CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py	2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/twistedcaldav/util.py	2014-04-04 16:31:48 UTC (rev 13154)
@@ -23,7 +23,7 @@
 from hashlib import md5, sha1
 
 from twisted.internet import ssl, reactor
-from twisted.internet.defer import inlineCallbacks, returnValue
+# from twisted.internet.defer import inlineCallbacks, returnValue
 from twisted.web import client
 from twisted.python import failure
 from twext.python.log import Logger
@@ -496,37 +496,39 @@
 
 
 
- at inlineCallbacks
-def normalizationLookup(cuaddr, principalFunction, config):
-    """
-    Lookup function to be passed to ical.normalizeCalendarUserAddresses.
-    Returns a tuple of (Full name, guid, and calendar user address list)
-    for the given cuaddr.  The principalFunction is called to retrieve the
-    principal for the cuaddr.
-    """
-    try:
-        record = yield principalFunction(cuaddr)
-    except Exception, e:
-        log.debug("Lookup of %s failed: %s" % (cuaddr, e))
-        record = None
+# @inlineCallbacks
+# def normalizationLookup(cuaddr, recordFunction, config):
+#     """
+#     Lookup function to be passed to ical.normalizeCalendarUserAddresses.
+#     Returns a tuple of (Full name C{str}, guid C{UUID}, and calendar user address list C{str})
+#     for the given cuaddr.  The recordFunction is called to retrieve the
+#     record for the cuaddr.
+#     """
+#     try:
+#         record = yield recordFunction(cuaddr)
+#     except Exception, e:
+#         log.debug("Lookup of %s failed: %s" % (cuaddr, e))
+#         record = None
 
-    if record is None:
-        returnValue((None, None, None))
-    else:
+#     if record is None:
+#         returnValue((None, None, None))
+#     else:
 
-        # RFC5545 syntax does not allow backslash escaping in
-        # parameter values. A double-quote is thus not allowed
-        # in a parameter value except as the start/end delimiters.
-        # Single quotes are allowed, so we convert any double-quotes
-        # to single-quotes.
-        fullName = record.displayName.replace('"', "'")
-        cuas = record.calendarUserAddresses
-        try:
-            guid = record.guid
-        except AttributeError:
-            guid = None
+#         # RFC5545 syntax does not allow backslash escaping in
+#         # parameter values. A double-quote is thus not allowed
+#         # in a parameter value except as the start/end delimiters.
+#         # Single quotes are allowed, so we convert any double-quotes
+#         # to single-quotes.
+#         fullName = record.displayName.replace('"', "'").encode("utf-8")
+#         cuas = set(
+#             [cua.encode("utf-8") for cua in record.calendarUserAddresses]
+#         )
+#         try:
+#             guid = record.guid
+#         except AttributeError:
+#             guid = None
 
-        returnValue((fullName, guid, cuas))
+#         returnValue((fullName, guid, cuas))
 
 
 

Modified: CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py
===================================================================
--- CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py	2014-04-04 02:40:16 UTC (rev 13153)
+++ CalendarServer/branches/users/sagen/move2who-4/txdav/caldav/datastore/util.py	2014-04-04 16:31:48 UTC (rev 13154)
@@ -104,7 +104,7 @@
 def normalizationLookup(cuaddr, recordFunction, config):
     """
     Lookup function to be passed to ical.normalizeCalendarUserAddresses.
-    Returns a tuple of (Full name, guid, and calendar user address list)
+    Returns a tuple of (Full name C{str}, guid C{UUID}, and calendar user address list C{str})
     for the given cuaddr.  The recordFunction is called to retrieve the
     record for the cuaddr.
     """
@@ -117,25 +117,25 @@
     if record is None:
         returnValue((None, None, None))
     else:
+
         # RFC5545 syntax does not allow backslash escaping in
         # parameter values. A double-quote is thus not allowed
         # in a parameter value except as the start/end delimiters.
         # Single quotes are allowed, so we convert any double-quotes
         # to single-quotes.
+        fullName = record.displayName.replace('"', "'").encode("utf-8")
+        cuas = set(
+            [cua.encode("utf-8") for cua in record.calendarUserAddresses]
+        )
         try:
             guid = record.guid
         except AttributeError:
             guid = None
-        returnValue(
-            (
-                record.displayName.replace('"', "'"),
-                guid,
-                record.calendarUserAddresses,
-            )
-        )
 
+        returnValue((fullName, guid, cuas))
 
 
+
 @inlineCallbacks
 def dropboxIDFromCalendarObject(calendarObject):
     """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140404/9905f0ee/attachment-0001.html>


More information about the calendarserver-changes mailing list