[CalendarServer-changes] [9273] CalendarServer/branches/users/glyph/uuid-normalize/twistedcaldav/ directory/augment.py

source_changes at macosforge.org source_changes at macosforge.org
Thu May 24 13:33:32 PDT 2012


Revision: 9273
          http://trac.macosforge.org/projects/calendarserver/changeset/9273
Author:   glyph at apple.com
Date:     2012-05-24 13:33:32 -0700 (Thu, 24 May 2012)
Log Message:
-----------
UUID normalizer for augment records.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/uuid-normalize/twistedcaldav/directory/augment.py

Modified: CalendarServer/branches/users/glyph/uuid-normalize/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/branches/users/glyph/uuid-normalize/twistedcaldav/directory/augment.py	2012-05-24 20:33:28 UTC (rev 9272)
+++ CalendarServer/branches/users/glyph/uuid-normalize/twistedcaldav/directory/augment.py	2012-05-24 20:33:32 UTC (rev 9273)
@@ -88,8 +88,32 @@
     def __init__(self):
         
         self.cachedRecords = {}
-    
+
+
     @inlineCallbacks
+    def normalizeUUIDs(self):
+        """
+        Normalize (uppercase) all augment UIDs which are parseable as UUIDs.
+
+        @return: a L{Deferred} that fires when all records have been
+            normalized.
+        """
+        from txdav.base.datastore.util import normalizeUUIDOrNot
+        remove = []
+        add = []
+        for uid in (yield self.getAllUIDs()):
+            nuid = normalizeUUIDOrNot(uid)
+            if uid != nuid:
+                old = yield self._lookupAugmentRecord(uid)
+                new = copy.deepcopy(old)
+                new.uid = uid.upper()
+                remove.append(old)
+                add.append(new)
+        yield self.removeAugmentRecords(remove)
+        yield self.addAugmentRecords(add)
+
+
+    @inlineCallbacks
     def getAugmentRecord(self, uid, recordType):
         """
         Get an AugmentRecord for the specified UID or the default.
@@ -244,16 +268,15 @@
         self.lastCached = time.time()
 
 
-    @inlineCallbacks
     def getAllUIDs(self):
         """
         Get all AugmentRecord UIDs.
 
         @return: L{Deferred}
         """
-        
         return succeed(self.db.keys())
 
+
     def _lookupAugmentRecord(self, uid):
         """
         Get an AugmentRecord for the specified UID.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120524/c378c78f/attachment-0001.html>


More information about the calendarserver-changes mailing list