[CalendarServer-changes] [5863] CalendarServer/branches/users/wsanchez/deployment

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 9 11:05:38 PDT 2010


Revision: 5863
          http://trac.macosforge.org/projects/calendarserver/changeset/5863
Author:   cdaboo at apple.com
Date:     2010-07-09 11:05:37 -0700 (Fri, 09 Jul 2010)
Log Message:
-----------
Allow for wildcard uids in augments DB. Change 'guid' to 'uid' to sync with trunk.

Modified Paths:
--------------
    CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/loadaugmentdb.py
    CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/manageaugments.py
    CalendarServer/branches/users/wsanchez/deployment/conf/augments-test.xml
    CalendarServer/branches/users/wsanchez/deployment/conf/augments.dtd
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/augment.py
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test-default.xml
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test.xml
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments.xml
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_augment.py
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_xmlfile.py
    CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/xmlaugmentsparser.py

Modified: CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/loadaugmentdb.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/loadaugmentdb.py	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/loadaugmentdb.py	2010-07-09 18:05:37 UTC (rev 5863)
@@ -156,23 +156,23 @@
 def run(dbxml):
     
     try:
-        guids = set((yield augment.AugmentService.getAllGUIDs()))
+        uids = set((yield augment.AugmentService.getAllUIDs()))
         added = 0
         updated = 0
         removed = 0
         if dbxml:
             for record in dbxml.db.values():
-                yield augment.AugmentService.addAugmentRecord(record, record.guid in guids)
-                if record.guid in guids:
+                yield augment.AugmentService.addAugmentRecord(record, record.uid in uids)
+                if record.uid in uids:
                     updated += 1
                 else:
                     added += 1
-            for guid in guids.difference(dbxml.db.keys()):
-                yield augment.AugmentService.removeAugmentRecord(guid)
+            for uid in uids.difference(dbxml.db.keys()):
+                yield augment.AugmentService.removeAugmentRecord(uid)
                 removed += 1
         else:
             yield augment.AugmentService.clean()
-            removed = len(guids)
+            removed = len(uids)
             
         print "Changes:"
         print "  Added: %d" % (added,)

Modified: CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/manageaugments.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/manageaugments.py	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/calendarserver/tools/manageaugments.py	2010-07-09 18:05:37 UTC (rev 5863)
@@ -63,11 +63,11 @@
     child = parent.find(tag)
     child.text = text
 
-def doAdd(xmlfile, guid, host, enable_calendar, auto_schedule):
+def doAdd(xmlfile, uid, host, enable_calendar, auto_schedule):
 
     augments_node = readXML(xmlfile)
 
-    # Make sure GUID is not already present
+    # Make sure UID is not already present
     for child in augments_node.getchildren():
         
         if child.tag != xmlaugmentsparser.ELEMENT_RECORD:
@@ -75,14 +75,14 @@
 
         for node in child.getchildren():
             
-            if node.tag == xmlaugmentsparser.ELEMENT_GUID and node.text == guid:
-                error("Cannot add guid '%s' because it already exists in augment file: '%s'" % (guid, xmlfile,))
+            if node.tag == xmlaugmentsparser.ELEMENT_UID and node.text == uid:
+                error("Cannot add uid '%s' because it already exists in augment file: '%s'" % (uid, xmlfile,))
     
     # Create new record
     if len(augments_node.getchildren()):
         augments_node.getchildren()[-1].tail = "\n  "
     record = addSubElement(augments_node, xmlaugmentsparser.ELEMENT_RECORD, "\n    ")
-    addSubElement(record, xmlaugmentsparser.ELEMENT_GUID, guid, 4)
+    addSubElement(record, xmlaugmentsparser.ELEMENT_UID, uid, 4)
     addSubElement(record, xmlaugmentsparser.ELEMENT_ENABLE, "true", 4)
     addSubElement(record, xmlaugmentsparser.ELEMENT_HOSTEDAT, host, 4)
     addSubElement(record, xmlaugmentsparser.ELEMENT_ENABLECALENDAR, "true" if enable_calendar else "false", 4)
@@ -90,13 +90,13 @@
     
     # Modify xmlfile
     writeXML(xmlfile, augments_node)
-    print "Added guid '%s' in augment file: '%s'" % (guid, xmlfile,)
+    print "Added uid '%s' in augment file: '%s'" % (uid, xmlfile,)
     
-def doModify(xmlfile, guid, host, enable_calendar, auto_schedule):
+def doModify(xmlfile, uid, host, enable_calendar, auto_schedule):
 
     augments_node = readXML(xmlfile)
 
-    # Make sure GUID is present
+    # Make sure UID is present
     for child in augments_node.getchildren():
         
         if child.tag != xmlaugmentsparser.ELEMENT_RECORD:
@@ -104,13 +104,13 @@
 
         for node in child.getchildren():
             
-            if node.tag == xmlaugmentsparser.ELEMENT_GUID and node.text == guid:
+            if node.tag == xmlaugmentsparser.ELEMENT_UID and node.text == uid:
                 break
         else:
             continue
         break
     else:
-        error("Cannot modify guid '%s' because it does not exist in augment file: '%s'" % (guid, xmlfile,))
+        error("Cannot modify uid '%s' because it does not exist in augment file: '%s'" % (uid, xmlfile,))
     
     # Modify record
     if host is not None:
@@ -120,13 +120,13 @@
     
     # Modify xmlfile
     writeXML(xmlfile, augments_node)
-    print "Modified guid '%s' in augment file: '%s'" % (guid, xmlfile,)
+    print "Modified uid '%s' in augment file: '%s'" % (uid, xmlfile,)
 
-def doRemove(xmlfile, guid):
+def doRemove(xmlfile, uid):
 
     augments_node = readXML(xmlfile)
 
-    # Make sure GUID is present
+    # Make sure UID is present
     for child in augments_node.getchildren():
         
         if child.tag != xmlaugmentsparser.ELEMENT_RECORD:
@@ -134,18 +134,18 @@
 
         for node in child.getchildren():
             
-            if node.tag == xmlaugmentsparser.ELEMENT_GUID and node.text == guid:
+            if node.tag == xmlaugmentsparser.ELEMENT_UID and node.text == uid:
                 break
         else:
             continue
         augments_node.remove(child)
         break
     else:
-        error("Cannot remove guid '%s' because it does not exist in augment file: '%s'" % (guid, xmlfile,))
+        error("Cannot remove uid '%s' because it does not exist in augment file: '%s'" % (uid, xmlfile,))
     
     # Modify xmlfile
     writeXML(xmlfile, augments_node)
-    print "Removed guid '%s' from augment file: '%s'" % (guid, xmlfile,)
+    print "Removed uid '%s' from augment file: '%s'" % (uid, xmlfile,)
     
 def doPrint(xmlfile):
 
@@ -173,43 +173,43 @@
 
     parser.add_option("-f", "--file", dest="xmlfilename",
                       help="XML augment file to manipulate", metavar="FILE")
-    parser.add_option("-g", "--guid", dest="guid",
-                      help="OD GUID to manipulate", metavar="GUID")
-    parser.add_option("-i", "--guidfile", dest="guidfile",
-                      help="File containing a list of GUIDs to manipulate", metavar="GUIDFILE")
+    parser.add_option("-g", "--uid", dest="uid",
+                      help="UID to manipulate", metavar="UID")
+    parser.add_option("-i", "--uidfile", dest="uidfile",
+                      help="File containing a list of UIDs to manipulate", metavar="UIDFILE")
     parser.add_option("-n", "--node", dest="node",
-                      help="Partition node to assign to GUID", metavar="NODE")
+                      help="Partition node to assign to UID", metavar="NODE")
     parser.add_option("-c", "--enable-calendar", action="store_true", dest="enable_calendar",
-                      default=True, help="Enable calendaring for this GUID: %default")
+                      default=True, help="Enable calendaring for this UID: %default")
     parser.add_option("-a", "--auto-schedule", action="store_true", dest="auto_schedule",
-                      default=False, help="Enable auto-schedule for this GUID: %default")
+                      default=False, help="Enable auto-schedule for this UID: %default")
 
     (options, args) = parser.parse_args()
 
     if len(args) != 1:
         parser.error("incorrect number of arguments")
 
-    guids = []
-    if options.guid:
-        guids.append(options.guid)
-    elif options.guidfile:
-        if not os.path.exists(options.guidfile):
-            parser.error("File containing list of GUIDs does not exist")
-        with open(options.guidfile) as f:
+    uids = []
+    if options.uid:
+        uids.append(options.uid)
+    elif options.uidfile:
+        if not os.path.exists(options.uidfile):
+            parser.error("File containing list of UIDs does not exist")
+        with open(options.uidfile) as f:
             for line in f:
-                guids.append(line[:-1])
+                uids.append(line[:-1])
         
     if args[0] == "add":
         if not options.node:
             parser.error("Partition node must be specified when adding")
-        for guid in guids:
-            doAdd(options.xmlfilename, guid, options.node, options.enable_calendar, options.auto_schedule)
+        for uid in uids:
+            doAdd(options.xmlfilename, uid, options.node, options.enable_calendar, options.auto_schedule)
     elif args[0] == "modify":
-        for guid in guids:
-            doModify(options.xmlfilename, guid, options.node, options.enable_calendar, options.auto_schedule)
+        for uid in uids:
+            doModify(options.xmlfilename, uid, options.node, options.enable_calendar, options.auto_schedule)
     elif args[0] == "remove":
-        for guid in guids:
-            doRemove(options.xmlfilename, guid)
+        for uid in uids:
+            doRemove(options.xmlfilename, uid)
     elif args[0] == "print":
         doPrint(options.xmlfilename)
 

Modified: CalendarServer/branches/users/wsanchez/deployment/conf/augments-test.xml
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/conf/augments-test.xml	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/conf/augments-test.xml	2010-07-09 18:05:37 UTC (rev 5863)
@@ -20,43 +20,43 @@
 
 <augments>
   <record>
-    <guid>admin</guid>
+    <uid>admin</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>apprentice</guid>
+    <uid>apprentice</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record repeat="99">
-    <guid>user%02d</guid>
+    <uid>user%02d</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record repeat="10">
-    <guid>public%02d</guid>
+    <uid>public%02d</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record repeat="10">
-    <guid>location%02d</guid>
+    <uid>location%02d</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
     <auto-schedule>true</auto-schedule>
   </record>
   <record repeat="10">
-    <guid>resource%02d</guid>
+    <uid>resource%02d</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
     <auto-schedule>true</auto-schedule>
   </record>
   <record repeat="4">
-    <guid>group%02d</guid>
+    <uid>group%02d</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>disabledgroup</guid>
+    <uid>disabledgroup</uid>
     <enable>false</enable>
   </record>
 </augments>

Modified: CalendarServer/branches/users/wsanchez/deployment/conf/augments.dtd
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/conf/augments.dtd	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/conf/augments.dtd	2010-07-09 18:05:37 UTC (rev 5863)
@@ -16,10 +16,10 @@
 
 <!ELEMENT augments (record*) >
 
-  <!ELEMENT record (guid, enable, hosted-at?, enable-calendar?, auto-schedule?)>
+  <!ELEMENT record (uid, enable, hosted-at?, enable-calendar?, auto-schedule?)>
     <!ATTLIST record repeat CDATA "1">
 
-  <!ELEMENT guid              (#PCDATA)>
+  <!ELEMENT uid               (#PCDATA)>
   <!ELEMENT enable            (#PCDATA)>
   <!ELEMENT hosted-at         (#PCDATA)>
   <!ELEMENT enable-calendar   (#PCDATA)>

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/augment.py	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/augment.py	2010-07-09 18:05:37 UTC (rev 5863)
@@ -33,13 +33,13 @@
 
     def __init__(
         self,
-        guid,
+        uid,
         enabled=False,
         hostedAt="",
         enabledForCalendaring=False,
         autoSchedule=False,
     ):
-        self.guid = guid
+        self.uid = uid
         self.enabled = enabled
         self.hostedAt = hostedAt
         self.enabledForCalendaring = enabledForCalendaring
@@ -51,56 +51,79 @@
     """
     
     def __init__(self):
-        pass
+        
+        self.cachedRecords = {}
     
     @inlineCallbacks
-    def getAugmentRecord(self, guid):
+    def getAugmentRecord(self, uid):
         """
-        Get an AugmentRecord for the specified GUID or the default.
+        Get an AugmentRecord for the specified UID or the default.
 
-        @param guid: directory GUID to lookup
-        @type guid: C{str}
+        @param uid: directory uid to lookup
+        @type uid: C{str}
         
         @return: L{Deferred}
         """
         
-        result = (yield self._lookupAugmentRecord(guid))
-        if result is None:
-            if not hasattr(self, "_defaultRecord"):
-                self._defaultRecord = (yield self._lookupAugmentRecord("Default"))
-            if self._defaultRecord is not None:
-                result = copy.deepcopy(self._defaultRecord)
-                result.guid = guid
-        returnValue(result)
+        result = (yield self._lookupAugmentRecord(uid))
+        if result is not None:
+            returnValue(result)
+        
+        # Try wildcard/default matches next
+        for lookup in ("%s*" % (uid[0:2],), "%s*" % (uid[0],), "Default"):
+            result = (yield self._cachedAugmentRecord(lookup))
+            if result is not None:
+                result = copy.deepcopy(result)
+                result.uid = uid
+                returnValue(result)
 
+        returnValue(None)
+
     @inlineCallbacks
-    def getAllGUIDs(self):
+    def getAllUIDs(self):
         """
-        Get all AugmentRecord GUIDs.
+        Get all AugmentRecord UIDs.
 
         @return: L{Deferred}
         """
         
         raise NotImplementedError("Child class must define this.")
 
-    def _lookupAugmentRecord(self, guid):
+    def _lookupAugmentRecord(self, uid):
         """
-        Get an AugmentRecord for the specified GUID.
+        Get an AugmentRecord for the specified uid.
 
-        @param guid: directory GUID to lookup
-        @type guid: C{str}
+        @param uid: directory uid to lookup
+        @type uid: C{str}
         
         @return: L{Deferred}
         """
         
         raise NotImplementedError("Child class must define this.")
 
+    @inlineCallbacks
+    def _cachedAugmentRecord(self, uid):
+        """
+        Get an AugmentRecord for the specified uid from the cache.
+
+        @param uid: directory uid to lookup
+        @type uid: C{str}
+        
+        @return: L{Deferred}
+        """
+        
+        if not uid in self.cachedRecords:
+            result = (yield self._lookupAugmentRecord(uid))
+            self.cachedRecords[uid] = result
+        returnValue(self.cachedRecords[uid])
+
     def refresh(self):
         """
         Refresh any cached data.
         """
-        pass
         
+        self.cachedRecords.clear()
+        
 AugmentService = AugmentDB()   # Global augment service
 
 
@@ -111,6 +134,7 @@
     
     def __init__(self, xmlFiles, cacheTimeout=30):
         
+        super(AugmentXMLDB, self).__init__()
         self.xmlFiles = xmlFiles
         self.cacheTimeout = cacheTimeout * 60 # Value is mins we want secs
         self.lastCached = 0
@@ -125,21 +149,21 @@
         self.lastCached = time.time()
 
     @inlineCallbacks
-    def getAllGUIDs(self):
+    def getAllUIDs(self):
         """
-        Get all AugmentRecord GUIDs.
+        Get all AugmentRecord UIDs.
 
         @return: L{Deferred}
         """
         
         return succeed(self.db.keys())
 
-    def _lookupAugmentRecord(self, guid):
+    def _lookupAugmentRecord(self, uid):
         """
-        Get an AugmentRecord for the specified GUID.
+        Get an AugmentRecord for the specified uid.
 
-        @param guid: directory GUID to lookup
-        @type guid: C{str}
+        @param uid: directory uid to lookup
+        @type uid: C{str}
         
         @return: L{Deferred}
         """
@@ -148,12 +172,13 @@
         if self.lastCached + self.cacheTimeout <= time.time():
             self.refresh()
             
-        return succeed(self.db.get(guid))
+        return succeed(self.db.get(uid))
 
     def refresh(self):
         """
         Refresh any cached data.
         """
+        super(AugmentXMLDB, self).refresh()
         try:
             self.db = self._parseXML()
         except RuntimeError:
@@ -181,43 +206,44 @@
     
     def __init__(self, dbID, dbapiName, dbapiArgs, **kwargs):
         
+        AugmentDB.__init__(self)
         self.cachedPartitions = {}
         self.cachedHostedAt = {}
         
         AbstractADBAPIDatabase.__init__(self, dbID, dbapiName, dbapiArgs, True, **kwargs)
         
     @inlineCallbacks
-    def getAllGUIDs(self):
+    def getAllUIDs(self):
         """
-        Get all AugmentRecord GUIDs.
+        Get all AugmentRecord UIDs.
 
         @return: L{Deferred}
         """
         
         # Query for the record information
-        results = (yield self.queryList("select GUID from AUGMENTS", ()))
+        results = (yield self.queryList("select UID from AUGMENTS", ()))
         returnValue(results)
 
     @inlineCallbacks
-    def _lookupAugmentRecord(self, guid):
+    def _lookupAugmentRecord(self, uid):
         """
-        Get an AugmentRecord for the specified GUID.
+        Get an AugmentRecord for the specified UID.
 
-        @param guid: directory GUID to lookup
-        @type guid: C{str}
+        @param uid: directory UID to lookup
+        @type uid: C{str}
 
         @return: L{Deferred}
         """
         
         # Query for the record information
-        results = (yield self.query("select GUID, ENABLED, PARTITIONID, CALENDARING, AUTOSCHEDULE from AUGMENTS where GUID = :1", (guid,)))
+        results = (yield self.query("select UID, ENABLED, PARTITIONID, CALENDARING, AUTOSCHEDULE from AUGMENTS where UID = :1", (uid,)))
         if not results:
             returnValue(None)
         else:
-            guid, enabled, partitionid, enabdledForCalendaring, autoSchedule = results[0]
+            uid, enabled, partitionid, enabdledForCalendaring, autoSchedule = results[0]
             
             record = AugmentRecord(
-                guid = guid,
+                uid = uid,
                 enabled = enabled == "T",
                 hostedAt = (yield self._getPartition(partitionid)),
                 enabledForCalendaring = enabdledForCalendaring == "T",
@@ -234,24 +260,24 @@
         if update:
             yield self.execute(
                 """update AUGMENTS set
-                   (GUID, ENABLED, PARTITIONID, CALENDARING, AUTOSCHEDULE) =
-                   (:1, :2, :3, :4, :5) where GUID = :6""",
+                   (UID, ENABLED, PARTITIONID, CALENDARING, AUTOSCHEDULE) =
+                   (:1, :2, :3, :4, :5) where UID = :6""",
                 (
-                    record.guid,
+                    record.uid,
                     "T" if record.enabled else "F",
                     partitionid,
                     "T" if record.enabledForCalendaring else "F",
                     "T" if record.autoSchedule else "F",
-                    record.guid,
+                    record.uid,
                 )
             )
         else:
             yield self.execute(
                 """insert into AUGMENTS
-                   (GUID, ENABLED, PARTITIONID, CALENDARING, AUTOSCHEDULE)
+                   (UID, ENABLED, PARTITIONID, CALENDARING, AUTOSCHEDULE)
                    values (:1, :2, :3, :4, :5)""",
                 (
-                    record.guid,
+                    record.uid,
                     "T" if record.enabled else "F",
                     partitionid,
                     "T" if record.enabledForCalendaring else "F",
@@ -259,9 +285,9 @@
                 )
             )
 
-    def removeAugmentRecord(self, guid):
+    def removeAugmentRecord(self, uid):
 
-        return self.query("delete from AUGMENTS where GUID = :1", (guid,))
+        return self.query("delete from AUGMENTS where UID = :1", (uid,))
 
     @inlineCallbacks
     def _getPartitionID(self, hostedat, createIfMissing=True):
@@ -314,7 +340,7 @@
         # TESTTYPE table
         #
         yield self._create_table("AUGMENTS", (
-            ("GUID",         "text unique"),
+            ("UID",          "text unique"),
             ("ENABLED",      "text(1)"),
             ("PARTITIONID",  "text"),
             ("CALENDARING",  "text(1)"),

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test-default.xml
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test-default.xml	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test-default.xml	2010-07-09 18:05:37 UTC (rev 5863)
@@ -20,44 +20,65 @@
 
 <augments>
   <record>
-    <guid>Default</guid>
+    <uid>Default</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
     <hosted-at>00001</hosted-at>
   </record>
   <record>
-    <guid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</guid>
+    <uid>AA*</uid>
     <enable>true</enable>
+    <hosted-at>00001</hosted-at>
   </record>
   <record>
-    <guid>6423F94A-6B76-4A3A-815B-D52CFD77935D</guid>
+    <uid>AB*</uid>
+    <enable>false</enable>
+  </record>
+  <record>
+    <uid>B*</uid>
     <enable>true</enable>
+    <hosted-at>00002</hosted-at>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>5A985493-EE2C-4665-94CF-4DFEA3A89500</guid>
+    <uid>C*</uid>
+    <enable>true</enable>
+    <hosted-at>00003</hosted-at>
+    <enable-calendar>true</enable-calendar>
+    <auto-schedule>true</auto-schedule>
+  </record>
+  <record>
+    <uid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</uid>
+    <enable>true</enable>
+  </record>
+  <record>
+    <uid>6423F94A-6B76-4A3A-815B-D52CFD77935D</uid>
+    <enable>true</enable>
+    <enable-calendar>true</enable-calendar>
+  </record>
+  <record>
+    <uid>5A985493-EE2C-4665-94CF-4DFEA3A89500</uid>
     <enable>false</enable>
   </record>
   <record>
-    <guid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</guid>
+    <uid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</uid>
     <enable>true</enable>
     <enable-calendar>false</enable-calendar>
   </record>
   <record>
-    <guid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</guid>
+    <uid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</uid>
     <enable>true</enable>
     <hosted-at>00001</hosted-at>
   </record>
   <record>
-    <guid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</guid>
+    <uid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</uid>
     <enable>true</enable>
     <hosted-at>00002</hosted-at>
   </record>
   <record>
-    <guid>6A73326A-F781-47E7-A9F8-AF47364D4152</guid>
+    <uid>6A73326A-F781-47E7-A9F8-AF47364D4152</uid>
     <enable>true</enable>
     <hosted-at>00002</hosted-at>
-    <enable>true</enable>
     <enable-calendar>true</enable-calendar>
     <auto-schedule>true</auto-schedule>
   </record>

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test.xml
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test.xml	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments-test.xml	2010-07-09 18:05:37 UTC (rev 5863)
@@ -20,35 +20,35 @@
 
 <augments>
   <record>
-    <guid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</guid>
+    <uid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>6423F94A-6B76-4A3A-815B-D52CFD77935D</guid>
+    <uid>6423F94A-6B76-4A3A-815B-D52CFD77935D</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>5A985493-EE2C-4665-94CF-4DFEA3A89500</guid>
+    <uid>5A985493-EE2C-4665-94CF-4DFEA3A89500</uid>
     <enable>false</enable>
   </record>
   <record>
-    <guid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</guid>
+    <uid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</uid>
     <enable>true</enable>
     <enable-calendar>false</enable-calendar>
   </record>
   <record>
-    <guid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</guid>
+    <uid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</uid>
     <enable>true</enable>
     <hosted-at>00001</hosted-at>
   </record>
   <record>
-    <guid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</guid>
+    <uid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</uid>
     <enable>true</enable>
     <hosted-at>00002</hosted-at>
   </record>
   <record>
-    <guid>6A73326A-F781-47E7-A9F8-AF47364D4152</guid>
+    <uid>6A73326A-F781-47E7-A9F8-AF47364D4152</uid>
     <enable>true</enable>
     <hosted-at>00002</hosted-at>
     <enable>true</enable>

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments.xml
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments.xml	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/augments.xml	2010-07-09 18:05:37 UTC (rev 5863)
@@ -20,109 +20,109 @@
 
 <augments realm="Test">
   <record>
-    <guid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</guid>
+    <uid>D11F03A0-97EA-48AF-9A6C-FAC7F3975766</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>6423F94A-6B76-4A3A-815B-D52CFD77935D</guid>
+    <uid>6423F94A-6B76-4A3A-815B-D52CFD77935D</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>5A985493-EE2C-4665-94CF-4DFEA3A89500</guid>
+    <uid>5A985493-EE2C-4665-94CF-4DFEA3A89500</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</guid>
+    <uid>8B4288F6-CC82-491D-8EF9-642EF4F3E7D0</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</guid>
+    <uid>5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</guid>
+    <uid>543D28BA-F74F-4D5F-9243-B3E3A61171E5</uid>
     <enable>true</enable>
     <enable-calendar>false</enable-calendar>
   </record>
   <record repeat="2">
-    <guid>user%02d</guid>
+    <uid>user%02d</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>9FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</guid>
+    <uid>9FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>admin</guid>
+    <uid>admin</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>grunts</guid>
+    <uid>grunts</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>right_coast</guid>
+    <uid>right_coast</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>left_coast</guid>
+    <uid>left_coast</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>both_coasts</guid>
+    <uid>both_coasts</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>recursive1_coasts</guid>
+    <uid>recursive1_coasts</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>recursive2_coasts</guid>
+    <uid>recursive2_coasts</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>non_calendar_group</guid>
+    <uid>non_calendar_group</uid>
     <enable>true</enable>
   </record>
   <record>
-    <guid>mercury</guid>
+    <uid>mercury</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>gemini</guid>
+    <uid>gemini</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
     <auto-schedule>true</auto-schedule>
   </record>
   <record>
-    <guid>apollo</guid>
+    <uid>apollo</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>orion</guid>
+    <uid>orion</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>transporter</guid>
+    <uid>transporter</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>ftlcpu</guid>
+    <uid>ftlcpu</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>
   <record>
-    <guid>non_calendar_proxy</guid>
+    <uid>non_calendar_proxy</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
   </record>

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_augment.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_augment.py	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_augment.py	2010-07-09 18:05:37 UTC (rev 5863)
@@ -26,39 +26,87 @@
 xmlFileDefault = os.path.join(os.path.dirname(__file__), "augments-test-default.xml")
 
 testRecords = (
-    {"guid":"D11F03A0-97EA-48AF-9A6C-FAC7F3975766", "enabled":True,  "hostedAt":"", "enabledForCalendaring":False, "autoSchedule":False},
-    {"guid":"6423F94A-6B76-4A3A-815B-D52CFD77935D", "enabled":True,  "hostedAt":"", "enabledForCalendaring":True, "autoSchedule":False},
-    {"guid":"5A985493-EE2C-4665-94CF-4DFEA3A89500", "enabled":False, "hostedAt":"", "enabledForCalendaring":False, "autoSchedule":False},
-    {"guid":"8B4288F6-CC82-491D-8EF9-642EF4F3E7D0", "enabled":True,  "hostedAt":"", "enabledForCalendaring":False, "autoSchedule":False},
-    {"guid":"5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1", "enabled":True,  "hostedAt":"00001", "enabledForCalendaring":False, "autoSchedule":False},
-    {"guid":"543D28BA-F74F-4D5F-9243-B3E3A61171E5", "enabled":True,  "hostedAt":"00002", "enabledForCalendaring":False, "autoSchedule":False},
-    {"guid":"6A73326A-F781-47E7-A9F8-AF47364D4152", "enabled":True,  "hostedAt":"00002", "enabledForCalendaring":True, "autoSchedule":True},
+    {"uid":"D11F03A0-97EA-48AF-9A6C-FAC7F3975766", "enabled":True,  "hostedAt":"",      "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"6423F94A-6B76-4A3A-815B-D52CFD77935D", "enabled":True,  "hostedAt":"",      "enabledForCalendaring":True,  "autoSchedule":False},
+    {"uid":"5A985493-EE2C-4665-94CF-4DFEA3A89500", "enabled":False, "hostedAt":"",      "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"8B4288F6-CC82-491D-8EF9-642EF4F3E7D0", "enabled":True,  "hostedAt":"",      "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1", "enabled":True,  "hostedAt":"00001", "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"543D28BA-F74F-4D5F-9243-B3E3A61171E5", "enabled":True,  "hostedAt":"00002", "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"6A73326A-F781-47E7-A9F8-AF47364D4152", "enabled":True,  "hostedAt":"00002", "enabledForCalendaring":True,  "autoSchedule":True },
 )
 
-testRecordDefault = {"guid":"A4318887-F2C7-4A70-9056-B88CC8DB26F1", "enabled":True,  "hostedAt":"00001", "enabledForCalendaring":True, "autoSchedule":False}
+testRecordWildcardDefault = (
+    {"uid":"A4318887-F2C7-4A70-9056-B88CC8DB26F1", "enabled":True,  "hostedAt":"00001", "enabledForCalendaring":True,  "autoSchedule":False},
+    {"uid":"AA5F935F-3358-4510-A649-B391D63279F2", "enabled":True,  "hostedAt":"00001", "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"ABF1A83B-1A29-4E04-BDC3-A6A66ECF27CA", "enabled":False, "hostedAt":"",      "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"BC22A734-5E41-4FB7-B5C1-51DC0656DC2F", "enabled":True,  "hostedAt":"00002", "enabledForCalendaring":True,  "autoSchedule":False},
+    {"uid":"C6DEEBB1-E14A-47F2-98BA-7E3BB4353E3A", "enabled":True,  "hostedAt":"00003", "enabledForCalendaring":True,  "autoSchedule":True },
+    {"uid":"AA859321-2C72-4974-ADCF-0CBA0C76F95D", "enabled":True,  "hostedAt":"00001", "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"AB7C488B-9ED2-4265-881C-7E2E38A63584", "enabled":False, "hostedAt":"",      "enabledForCalendaring":False, "autoSchedule":False},
+    {"uid":"BB0C0DA1-0545-45F6-8D08-917C554D93A4", "enabled":True,  "hostedAt":"00002", "enabledForCalendaring":True,  "autoSchedule":False},
+    {"uid":"CCD30AD3-582F-4682-8B65-2EDE92C5656E", "enabled":True,  "hostedAt":"00003", "enabledForCalendaring":True,  "autoSchedule":True },
+)
 
 class AugmentTests(TestCase):
 
     @inlineCallbacks
     def _checkRecord(self, db, items):
         
-        record = (yield db.getAugmentRecord(items["guid"]))
+        record = (yield db.getAugmentRecord(items["uid"]))
         self.assertTrue(record is not None)
         
         for k,v in items.iteritems():
             self.assertEqual(getattr(record, k), v)
 
     @inlineCallbacks
-    def _checkNoRecord(self, db, guid):
+    def _checkNoRecord(self, db, uid):
         
-        record = (yield db.getAugmentRecord(guid))
+        record = (yield db.getAugmentRecord(uid))
         self.assertTrue(record is None)
 
-class AugmentXMLTests(AugmentTests):
+class AugmentTestsMixin(object):
 
+    def _db(self):
+        raise NotImplementedError
+
     @inlineCallbacks
     def test_read(self):
         
+        db = self._db()
+
+        dbxml = AugmentXMLDB((xmlFile,))
+        for record in dbxml.db.values():
+            yield db.addAugmentRecord(record)
+
+        for item in testRecords:
+            yield self._checkRecord(db, item)
+
+        yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
+
+    @inlineCallbacks
+    def test_read_default(self):
+        
+        db = self._db()
+
+        dbxml = AugmentXMLDB((xmlFileDefault,))
+        for record in dbxml.db.values():
+            yield db.addAugmentRecord(record)
+
+        for item in testRecords:
+            yield self._checkRecord(db, item)
+
+        for item in testRecordWildcardDefault:
+            yield self._checkRecord(db, item)
+
+        # Do a second time to test caching
+        for item in testRecordWildcardDefault:
+            yield self._checkRecord(db, item)
+
+class AugmentXMLTests(AugmentTests, AugmentTestsMixin):
+
+    @inlineCallbacks
+    def test_read(self):
+        
         db = AugmentXMLDB((xmlFile,))
 
         for item in testRecords:
@@ -74,7 +122,8 @@
         for item in testRecords:
             yield self._checkRecord(db, item)
 
-        yield self._checkRecord(db, testRecordDefault)
+        for item in testRecordWildcardDefault:
+            yield self._checkRecord(db, item)
 
     def test_parseErrors(self):
         
@@ -99,74 +148,22 @@
 """), db)
         self.assertRaises(RuntimeError, XMLAugmentsParser, cStringIO.StringIO("""<?xml version="1.0" encoding="utf-8"?>
   <record>
-    <guid>admin</guid>
+    <uid>admin</uid>
     <enable>true</enable>
     <foo/>
   </record>
 """), db)
 
-class AugmentSqliteTests(AugmentTests):
+class AugmentSqliteTests(AugmentTests, AugmentTestsMixin):
 
-    @inlineCallbacks
-    def test_read(self):
-        
-        db = AugmentSqliteDB(self.mktemp())
+    def _db(self):
+        return AugmentSqliteDB(self.mktemp())
 
-        dbxml = AugmentXMLDB((xmlFile,))
-        for record in dbxml.db.values():
-            yield db.addAugmentRecord(record)
+class AugmentPostgreSQLTests(AugmentTests, AugmentTestsMixin):
 
-        for item in testRecords:
-            yield self._checkRecord(db, item)
+    def _db(self):
+        return AugmentPostgreSQLDB("localhost", "augments")
 
-        yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
-
-    @inlineCallbacks
-    def test_read_default(self):
-        
-        db = AugmentSqliteDB(self.mktemp())
-
-        dbxml = AugmentXMLDB((xmlFileDefault,))
-        for record in dbxml.db.values():
-            yield db.addAugmentRecord(record)
-
-        for item in testRecords:
-            yield self._checkRecord(db, item)
-
-        yield self._checkRecord(db, testRecordDefault)
-
-class AugmentPostgreSQLTests(AugmentTests):
-
-    @inlineCallbacks
-    def test_read(self):
-        
-        db = AugmentPostgreSQLDB("localhost", "augments")
-        yield db.clean()
-
-        dbxml = AugmentXMLDB((xmlFile,))
-        for record in dbxml.db.values():
-            yield db.addAugmentRecord(record)
-
-        for item in testRecords:
-            yield self._checkRecord(db, item)
-
-        yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
-
-    @inlineCallbacks
-    def test_read_default(self):
-        
-        db = AugmentPostgreSQLDB("localhost", "augments")
-        yield db.clean()
-
-        dbxml = AugmentXMLDB((xmlFileDefault,))
-        for record in dbxml.db.values():
-            yield db.addAugmentRecord(record)
-
-        for item in testRecords:
-            yield self._checkRecord(db, item)
-
-        yield self._checkRecord(db, testRecordDefault)
-
 try:
     import pgdb
 except ImportError:

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_xmlfile.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_xmlfile.py	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/test/test_xmlfile.py	2010-07-09 18:05:37 UTC (rev 5863)
@@ -154,7 +154,7 @@
 <!DOCTYPE accounts SYSTEM "accounts.dtd">
 <augments>
   <record>
-    <guid>myoffice</guid>
+    <uid>myoffice</uid>
     <enable>true</enable>
     <enable-calendar>true</enable-calendar>
     <auto-schedule>true</auto-schedule>

Modified: CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/xmlaugmentsparser.py
===================================================================
--- CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/xmlaugmentsparser.py	2010-07-09 02:37:58 UTC (rev 5862)
+++ CalendarServer/branches/users/wsanchez/deployment/twistedcaldav/directory/xmlaugmentsparser.py	2010-07-09 18:05:37 UTC (rev 5863)
@@ -33,7 +33,7 @@
 ELEMENT_AUGMENTS          = "augments"
 ELEMENT_RECORD            = "record"
 
-ELEMENT_GUID              = "guid"
+ELEMENT_UID               = "uid"
 ELEMENT_ENABLE            = "enable"
 ELEMENT_HOSTEDAT          = "hosted-at"
 ELEMENT_ENABLECALENDAR    = "enable-calendar"
@@ -45,7 +45,7 @@
 VALUE_FALSE               = "false"
 
 ELEMENT_AUGMENTRECORD_MAP = {
-    ELEMENT_GUID:           "guid",
+    ELEMENT_UID:            "uid",
     ELEMENT_ENABLE:         "enabled",
     ELEMENT_HOSTEDAT:       "hostedAt",
     ELEMENT_ENABLECALENDAR: "enabledForCalendaring",
@@ -93,7 +93,7 @@
             for node in child.getchildren():
                 
                 if node.tag in (
-                    ELEMENT_GUID,
+                    ELEMENT_UID,
                     ELEMENT_HOSTEDAT,
                 ):
                     fields[node.tag] = node.text
@@ -106,9 +106,9 @@
                 else:
                     log.error("Invalid element '%s' in augment file: '%s'" % (node.tag, self.xmlFile,), raiseException=RuntimeError)
                     
-            # Must have at least a guid
-            if ELEMENT_GUID not in fields:
-                log.error("Invalid record '%s' without a guid in augment file: '%s'" % (child, self.xmlFile,), raiseException=RuntimeError)
+            # Must have at least a uid
+            if ELEMENT_UID not in fields:
+                log.error("Invalid record '%s' without a uid in augment file: '%s'" % (child, self.xmlFile,), raiseException=RuntimeError)
                 
             if repeat > 1:
                 for i in xrange(1, repeat+1):
@@ -134,4 +134,4 @@
             actualFields[ELEMENT_AUGMENTRECORD_MAP[k]] = expandCount(v, count)
 
         record = AugmentRecord(**actualFields)
-        self.items[record.guid] = record
+        self.items[record.uid] = record
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100709/ccd46d6f/attachment-0001.html>


More information about the calendarserver-changes mailing list