[CalendarServer-changes] [4124] CalendarServer/trunk/twistedcaldav/directory

source_changes at macosforge.org source_changes at macosforge.org
Fri May 1 09:17:07 PDT 2009


Revision: 4124
          http://trac.macosforge.org/projects/calendarserver/changeset/4124
Author:   sagen at apple.com
Date:     2009-05-01 09:17:03 -0700 (Fri, 01 May 2009)
Log Message:
-----------
Since faulting in of the records of local users by their GUID doesn't seem to work, this workaround forces a lookup of the imip injection user by shortname, and indexes it on GUID, and doesn't expire the record.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py
    CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py

Modified: CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py	2009-05-01 02:03:56 UTC (rev 4123)
+++ CalendarServer/trunk/twistedcaldav/directory/cachingappleopendirectory.py	2009-05-01 16:17:03 UTC (rev 4124)
@@ -98,6 +98,21 @@
         self._records = {}
         self._delayedCalls = set()
 
+
+        # Special handling of the local user used for iMIP injection:
+        # Faulting by GUID doesn't work for local users, so we need to
+        # force the iMIP user into our GUID index and set the record
+        # to never expire.
+        if config.Scheduling.iMIP.Enabled:
+            imipUserName = config.Scheduling.iMIP.Username
+            if imipUserName:
+                imipRecord = self.recordWithShortName(self.recordType_users,
+                    imipUserName)
+                if imipRecord:
+                    self.recordCacheForType(self.recordType_users).addRecord(
+                        imipRecord, self.INDEX_TYPE_GUID, imipRecord.guid,
+                        neverExpire=True)
+
     def __cmp__(self, other):
         if not isinstance(other, DirectoryRecord):
             return super(DirectoryRecord, self).__eq__(other)

Modified: CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py	2009-05-01 02:03:56 UTC (rev 4123)
+++ CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py	2009-05-01 16:17:03 UTC (rev 4124)
@@ -46,7 +46,8 @@
         self.directoryService = directoryService
         self.recordType = recordType
 
-    def addRecord(self, record, indexType, indexKey, useMemcache=True):
+    def addRecord(self, record, indexType, indexKey, useMemcache=True,
+        neverExpire=False):
         raise NotImplementedError()
     
     def removeRecord(self, record):
@@ -71,10 +72,14 @@
             CachingDirectoryService.INDEX_TYPE_AUTHID   : {},
         }
 
-    def addRecord(self, record, indexType, indexKey, useMemcache=True):
+    def addRecord(self, record, indexType, indexKey, useMemcache=True,
+        neverExpire=False):
 
         useMemcache == useMemcache and config.Memcached.ClientEnabled
 
+        if neverExpire:
+            record.neverExpire()
+
         self.records.add(record)
 
         self.recordsIndexedBy[indexType][indexKey] = record
@@ -116,7 +121,7 @@
 
     INDEX_TYPE_GUID      = "guid"
     INDEX_TYPE_SHORTNAME = "shortname"
-    INDEX_TYPE_CUA     = "cua"
+    INDEX_TYPE_CUA       = "cua"
     INDEX_TYPE_AUTHID    = "authid"
 
     indexTypeToRecordAttribute = {
@@ -138,6 +143,7 @@
         self.cacheTimeout = cacheTimeout * 60
 
         self._initCaches(cacheClass)
+
         super(CachingDirectoryService, self).__init__()
 
     def _getMemcacheClient(self, refresh=False):
@@ -240,7 +246,10 @@
             for recordType in recordTypes:
                 record = self.recordCacheForType(recordType).findRecord(indexType, indexKey)
                 if record:
-                    if (time.time() - record.cachedTime > self.cacheTimeout):
+                    if (
+                        record.cachedTime != 0 and
+                        time.time() - record.cachedTime > self.cacheTimeout
+                    ):
                         self.recordCacheForType(recordType).removeRecord(record)
                         return None
                     else:
@@ -330,6 +339,9 @@
         
         self.cachedTime = time.time()
 
+    def neverExpire(self):
+        self.cachedTime = 0
+
 class DirectoryMemcacheError(DirectoryError):
     """
     Error communicating with memcached.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090501/224d724d/attachment.html>


More information about the calendarserver-changes mailing list