[CalendarServer-changes] [8843] CalendarServer/branches/users/gaya/ldapdirectorybacker
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 12 14:23:40 PDT 2012
Revision: 8843
http://trac.macosforge.org/projects/calendarserver/changeset/8843
Author: gaya at apple.com
Date: 2012-03-12 14:23:40 -0700 (Mon, 12 Mar 2012)
Log Message:
-----------
remove caching from opendirectorybacker
Modified Paths:
--------------
CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/carddav-ldaptest.plist
CalendarServer/branches/users/gaya/ldapdirectorybacker/support/CalendarServer.xcodeproj/project.pbxproj
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/directory.py
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/ldapdirectorybacker.py
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directorybackedaddressbook.py
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_multiget_common.py
CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/stdconfig.py
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/carddav-ldaptest.plist
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/carddav-ldaptest.plist 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/conf/carddav-ldaptest.plist 2012-03-12 21:23:40 UTC (rev 8843)
@@ -1040,18 +1040,9 @@
<!- ignore system records like "root" when creating vCards ->
<key>ignoreSystemRecords</key>
<true/>
- <!- True to use a directory service query for each addressBook-query to the directory address book ->
- <key>liveQuery</key>
- <true/>
<!- fake the eTag. If false all directory service attributes are used to calculate the eTag ->
<key>fakeETag</key>
<true/>
- <!- True to store the results on disk after a directory service query. True is usually much slower. ->
- <key>cacheQuery</key>
- <false/>
- <!- If cacheQuery is True and liveQuery is False, the minutes to keep the results from a complete directory service all record query. ->
- <key>cacheTimeout</key>
- <integer>30</integer>
<key>standardizeSyntheticUIDs</key>
<true/>
<key>appleInternalServer</key>
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/support/CalendarServer.xcodeproj/project.pbxproj
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/support/CalendarServer.xcodeproj/project.pbxproj 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/support/CalendarServer.xcodeproj/project.pbxproj 2012-03-12 21:23:40 UTC (rev 8843)
@@ -39,7 +39,6 @@
66EAD05B150AF4EB00B8C5A7 /* watch_memcached */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = watch_memcached; sourceTree = "<group>"; };
66EAD061150AF4EB00B8C5A7 /* _sacl.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = _sacl.o; sourceTree = "<group>"; };
66EAD064150AF4EB00B8C5A7 /* sendmsg.o */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.objfile"; path = sendmsg.o; sourceTree = "<group>"; };
- 66EAD065150AF4EB00B8C5A7 /* caldavd-dev.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "caldavd-dev.plist"; path = "../caldavd-dev.plist"; sourceTree = "<group>"; };
66EAD067150AF4EB00B8C5A7 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
66EAD068150AF4EB00B8C5A7 /* accesslog.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = accesslog.py; sourceTree = "<group>"; };
66EAD06A150AF4EB00B8C5A7 /* __init__.py */ = {isa = PBXFileReference; lastKnownFileType = text.script.python; path = __init__.py; sourceTree = "<group>"; };
@@ -156,7 +155,7 @@
66EAD0F1150AF4EB00B8C5A7 /* caldavd-partitioning-secondary.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "caldavd-partitioning-secondary.plist"; sourceTree = "<group>"; };
66EAD0F2150AF4EB00B8C5A7 /* caldavd-test.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "caldavd-test.plist"; sourceTree = "<group>"; };
66EAD0F3150AF4EB00B8C5A7 /* caldavd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = caldavd.plist; sourceTree = "<group>"; };
- 66EAD0F4150AF4EB00B8C5A7 /* carddav-ldapdirtest.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "carddav-ldapdirtest.plist"; sourceTree = "<group>"; };
+ 66EAD0F4150AF4EB00B8C5A7 /* carddav-ldaptest.plist */ = {isa = PBXFileReference; path = "carddav-ldaptest.plist"; sourceTree = "<group>"; };
66EAD0F5150AF4EB00B8C5A7 /* mime.types */ = {isa = PBXFileReference; lastKnownFileType = text; path = mime.types; sourceTree = "<group>"; };
66EAD0F7150AF4EB00B8C5A7 /* caldavd-resources.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "caldavd-resources.plist"; sourceTree = "<group>"; };
66EAD0F8150AF4EB00B8C5A7 /* locations-resources-orig.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "locations-resources-orig.xml"; sourceTree = "<group>"; };
@@ -1615,7 +1614,6 @@
66EAD03E150AF4EB00B8C5A7 /* benchreport */,
66EAD03F150AF4EB00B8C5A7 /* bin */,
66EAD05C150AF4EB00B8C5A7 /* build */,
- 66EAD065150AF4EB00B8C5A7 /* caldavd-dev.plist */,
66EAD066150AF4EB00B8C5A7 /* calendarserver */,
66EAD0E3150AF4EB00B8C5A7 /* conf */,
66EAD103150AF4EB00B8C5A7 /* contrib */,
@@ -2037,7 +2035,7 @@
66EAD0F1150AF4EB00B8C5A7 /* caldavd-partitioning-secondary.plist */,
66EAD0F2150AF4EB00B8C5A7 /* caldavd-test.plist */,
66EAD0F3150AF4EB00B8C5A7 /* caldavd.plist */,
- 66EAD0F4150AF4EB00B8C5A7 /* carddav-ldapdirtest.plist */,
+ 66EAD0F4150AF4EB00B8C5A7 /* carddav-ldaptest.plist */,
66EAD0F5150AF4EB00B8C5A7 /* mime.types */,
66EAD0F6150AF4EB00B8C5A7 /* resources */,
66EAD0FB150AF4EB00B8C5A7 /* resources.xml */,
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/directory.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/directory.py 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/directory.py 2012-03-12 21:23:40 UTC (rev 8843)
@@ -96,9 +96,6 @@
baseGUID = None
guid = property(_generatedGUID)
- # Needed by twistedcaldav.directorybackedaddressbook
- liveQuery = False
-
def setRealm(self, realmName):
self.realmName = realmName
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/ldapdirectorybacker.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/ldapdirectorybacker.py 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/ldapdirectorybacker.py 2012-03-12 21:23:40 UTC (rev 8843)
@@ -163,11 +163,8 @@
self.maxQueryRecords = maxQueryRecords
- self.realmName = None # needed for super
- self.liveQuery = True # used by directorybackedaddressbook.py
- self.cacheQuery = False
+ self.realmName = None # needed for super
-
### used by VCardRecord.
self.fakeETag = fakeETag
self.addDSAttrXProperties = False
@@ -201,17 +198,10 @@
h = (h + hash(getattr(self, attr))) & sys.maxint
return h
- @inlineCallbacks
- def available(self):
- returnValue(True)
-
-
#@inlineCallbacks
def createCache(self):
succeed(None)
-
-
#to do: use opendirectorybacker._getDSFilter passing in search map
def _getLdapFilter(self, addressBookFilter, searchmap):
"""
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directory/opendirectorybacker.py 2012-03-12 21:23:40 UTC (rev 8843)
@@ -88,12 +88,8 @@
dsLocalCacheTimeout = 30,
ignoreSystemRecords = True,
- liveQuery = True, # query directory service as needed
- fakeETag = True, # eTag is not reliable if True
-
- cacheQuery = False,
- cacheTimeout=30, # cache timeout
-
+ fakeETag = True, # eTag is not reliable if True
+
addDSAttrXProperties=False, # add dsattributes to vcards as "X-" attributes
standardizeSyntheticUIDs = False, # use simple synthetic UIDs --- good for testing
appleInternalServer=False,
@@ -108,10 +104,7 @@
@maxDSQueryRecords: maximum number of (unfiltered) ds records retrieved before raising
NumberOfMatchesWithinLimits exception or returning results
@dsLocalCacheTimeout: how log to keep cache of DSLocal records
- @liveQuery: C{True} to query the directory as needed
@fakeETag: C{True} to use a fake eTag; allows ds queries with partial attributes
- @cacheQuery: C{True} to query the directory and cache results
- @cacheTimeout: if caching, the average cache timeout
@standardizeSyntheticUIDs: C{True} when creating synthetic UID (==f(Node, Type, Record Name)),
use a standard Node name. This allows testing with the same UID on different hosts
@allowedAttributes: list of DSAttributes that are used to create VCards
@@ -161,13 +154,8 @@
self.queryDSLocal = queryDSLocal
self.dsLocalCacheTimeout = dsLocalCacheTimeout
- self.liveQuery = liveQuery or not cacheQuery
self.fakeETag = fakeETag
-
- self.cacheQuery = cacheQuery
-
- self.cacheTimeout = cacheTimeout if cacheTimeout > 0 else 30
-
+
self.addDSAttrXProperties = addDSAttrXProperties
self.standardizeSyntheticUIDs = standardizeSyntheticUIDs
self.appleInternalServer = appleInternalServer
@@ -202,23 +190,7 @@
else:
self.defaultNodeName = None
- #cleanup
- self._cleanupTime = time.time()
-
- # file system locks
- self._initLockPath = join(config.DocumentRoot, ".directory_address_book_create_lock")
- self._createdLockPath = join(config.DocumentRoot, ".directory_address_book_created_lock")
- self._updateLockPath = join(config.DocumentRoot, ".directory_address_book_update_lock")
- self._tmpDirAddressBookLockPath = join(config.DocumentRoot, ".directory_address_book_tmpFolder_lock")
-
- self._updateLock = MemcacheLock("OpenDirectoryBacker", self._updateLockPath)
- self._tmpDirAddressBookLock = MemcacheLock("OpenDirectoryBacker", self._tmpDirAddressBookLockPath)
-
- # optimization so we don't have to always create lock
- self._triedCreateLock = False
- self._created = False
-
def __cmp__(self, other):
if not isinstance(other, DirectoryRecord):
return super(DirectoryRecord, self).__eq__(other)
@@ -235,197 +207,9 @@
h = (h + hash(getattr(self, attr))) & sys.maxint
return h
- @inlineCallbacks
- def available(self):
- if not self._triedCreateLock:
- returnValue( False )
- elif not self._created:
- createdLock = MemcacheLock("OpenDirectoryBacker", self._createdLockPath)
- self.log_debug("blocking on lock of: \"%s\")" % self._createdLockPath)
- self._created = (yield createdLock.locked())
-
- returnValue(self._created)
-
-
- def updateLock(self):
- return self._updateLock
-
-
- @inlineCallbacks
def createCache(self):
- """
- If caching, create the cache for the first time.
- """
-
- if not self.liveQuery:
- self.log_info("loading directory address book")
-
- # get init lock
- initLock = MemcacheLock("OpenDirectoryBacker", self._initLockPath, timeout=0)
- self.log_debug("Attempt lock of: \"%s\")" % self._initLockPath)
- gotCreateLock = False
- try:
- yield initLock.acquire()
- gotCreateLock = True
- except MemcacheLockTimeoutError:
- pass
-
- self._triedCreateLock = True
-
- if gotCreateLock:
- self.log_debug("Got lock!")
- yield self._refreshCache( flushCache=False, creating=True )
- else:
- self.log_debug("Could not get lock - directory address book will be filled by peer")
-
-
+ succeed(None)
- @inlineCallbacks
- def _refreshCache(self, flushCache=False, creating=False, reschedule=True, query=None, attributes=None, keepLock=False, clear=False, maxRecords=0 ):
- """
- refresh the cache.
- """
-
- #print("_refreshCache:, flushCache=%s, creating=%s, reschedule=%s, query = %s" % (flushCache, creating, reschedule, "None" if query is None else query.generate(),))
-
- def refreshLater():
- #
- # Add jitter/fuzz factor to avoid stampede for large OD query
- #
- cacheTimeout = min(self.cacheTimeout, 60) * 60
- cacheTimeout = (cacheTimeout * random()) - (cacheTimeout / 2)
- cacheTimeout += self.cacheTimeout * 60
- reactor.callLater(cacheTimeout, self._refreshCache) #@UndefinedVariable
- self.log_info("Refresh directory address book in %d minutes %d seconds" % divmod(cacheTimeout, 60))
-
- def cleanupLater():
-
- # try to cancel previous call if last clean up was less than 15 minutes ago
- if (time.time() - self._cleanupTime) < 15*60:
- try:
- self._lastCleanupCall.cancel()
- except:
- pass
-
- #
- # Add jitter/fuzz factor
- #
- nom = 120
- later = nom* (random() + .5)
- self._lastCleanupCall = reactor.callLater(later, removeTmpAddressBooks) #@UndefinedVariable
- self.log_info("Remove temporary directory address books in %d minutes %d seconds" % divmod(later, 60))
-
-
- def getTmpDirAndTmpFilePrefixSuffix():
- # need to have temp file on same volumes as documents so that move works
- absDocPath = abspath(config.DocumentRoot)
- if absDocPath.startswith("/Volumes/"):
- tmpDir = absDocPath
- prefix = ".directoryAddressBook-"
- else:
- tmpDir = gettempdir()
- prefix = "directoryAddressBook-"
-
- return (tmpDir, prefix, ".tmp")
-
- def makeTmpFilename():
- tmpDir, prefix, suffix = getTmpDirAndTmpFilePrefixSuffix()
- fd, fname = mkstemp(suffix=suffix, prefix=prefix, dir=tmpDir)
- os.close(fd)
- os.remove(fname)
- return fname
-
- @inlineCallbacks
- def removeTmpAddressBooks():
- self.log_info("Checking for temporary directory address books")
- tmpDir, prefix, suffix = getTmpDirAndTmpFilePrefixSuffix()
-
- tmpDirLock = self._tmpDirAddressBookLock
- self.log_debug("blocking on lock of: \"%s\")" % self._tmpDirAddressBookLockPath)
- yield tmpDirLock.acquire()
-
- try:
- for name in listdir(tmpDir):
- if name.startswith(prefix) and name.endswith(suffix):
- try:
- path = join(tmpDir, name)
- self.log_info("Deleting temporary directory address book at: %s" % path)
- FilePath(path).remove()
- self.log_debug("Done deleting")
- except:
- self.log_info("Deletion failed")
- finally:
- self.log_debug("unlocking: \"%s\")" % self._tmpDirAddressBookLockPath)
- yield tmpDirLock.release()
-
- self._cleanupTime = time.time()
-
-
- updateLock = None
- limited = False
- try:
-
- try:
- # get the records
- if clear:
- records = {}
- else:
- records, limited = (yield self._getDirectoryRecords(query, attributes, maxRecords))
-
- # calculate the hash
- # simple for now, could use MD5 digest if too many collisions
- newAddressBookCTag = customxml.GETCTag(str(hash(self.baseGUID + ":" + self.realmName + ":" + "".join(str(hash(records[key])) for key in records.keys()))))
-
- # get the old hash
- oldAddressBookCTag = ""
- updateLock = self.updateLock()
- self.log_debug("blocking on lock of: \"%s\")" % self._updateLockPath)
- yield updateLock.acquire()
-
- if not flushCache:
- # get update lock
- try:
- oldAddressBookCTag = self.directoryBackedAddressBook.readDeadProperty((calendarserver_namespace, "getctag"))
- except:
- oldAddressBookCTag = ""
-
- self.log_debug("Comparing {http://calendarserver.org/ns/}getctag: new = %s, old = %s" % (newAddressBookCTag, oldAddressBookCTag))
- if str(newAddressBookCTag) != str(oldAddressBookCTag):
-
- self.log_debug("unlocking: \"%s\")" % self._updateLockPath)
- yield updateLock.release()
- updateLock = None
-
-
- if not keepLock:
- self.log_debug("unlocking: \"%s\")" % self._updateLockPath)
- yield updateLock.release()
- updateLock = None
-
- except:
- cleanupLater()
- if reschedule:
- refreshLater()
- raise
-
- if creating:
- createdLock = MemcacheLock("OpenDirectoryBacker", self._createdLockPath)
- self.log_debug("blocking on lock of: \"%s\")" % self._createdLockPath)
- yield createdLock.acquire()
-
- cleanupLater()
- if reschedule:
- refreshLater()
-
- except:
- if updateLock:
- yield updateLock.release()
- raise
-
- returnValue( (updateLock, limited) )
-
-
-
def _getDSLocalRecords(self):
def generateDSLocalRecords():
@@ -475,7 +259,7 @@
return records
- if not self.liveQuery or not self.queryDSLocal:
+ if not self.queryDSLocal:
return {}
if time.time() > self._nextDSLocalQueryTime:
@@ -962,43 +746,7 @@
return list(set(queryAttributes).intersection(set(self.returnedAttributes)))
- @inlineCallbacks
- def cacheVCardsForAddressBookQuery(self, addressBookFilter, addressBookQuery, maxResults ):
- """
- Cache the vCards for a given addressBookFilder and addressBookQuery
- """
- startTime = time.time()
- #print("Timing: cacheVCardsForAddressBookQuery.starttime=%f" % startTime)
-
-
- allRecords, filterAttributes, dsFilter = self._getDSFilter( addressBookFilter );
- #print("allRecords = %s, query = %s" % (allRecords, "None" if dsFilter is None else dsFilter.generate(),))
-
- if allRecords:
- dsFilter = None # None expression == all Records
- clear = not allRecords and not dsFilter
-
- #get unique list of requested attributes
- if clear:
- attributes = None
- else:
- queryAttributes = self._attributesForAddressBookQuery( addressBookQuery )
- attributes = filterAttributes + queryAttributes
-
- #calc maxRecords from passed in maxResults allowing extra for second stage filtering in caller
- maxRecords = int(maxResults * 1.2)
- if self.maxDSQueryRecords and maxRecords > self.maxDSQueryRecords:
- maxRecords = self.maxDSQueryRecords
-
- updateLock, limited = (yield self._refreshCache(reschedule=False, query=dsFilter, attributes=attributes, keepLock=True, clear=clear, maxRecords=maxRecords ))
- elaspedTime = time.time()-startTime
- self.log_info("Timing: Cache fill: %.1f ms" % (elaspedTime*1000,))
-
-
- returnValue((updateLock, limited))
-
-
@inlineCallbacks
def vCardRecordsForAddressBookQuery(self, addressBookFilter, addressBookQuery, maxResults ):
"""
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directorybackedaddressbook.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directorybackedaddressbook.py 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/directorybackedaddressbook.py 2012-03-12 21:23:40 UTC (rev 8843)
@@ -156,22 +156,6 @@
def renderHTTP(self, request):
if not self.directory:
raise HTTPError(StatusResponse(responsecode.SERVICE_UNAVAILABLE,"Service is starting up" ))
- elif self.directory.liveQuery:
- response = (yield maybeDeferred(super(DirectoryBackedAddressBookResource, self).renderHTTP, request))
- returnValue(response)
- else:
- available = (yield maybeDeferred(self.directory.available, ))
-
- if not available:
- raise HTTPError(StatusResponse(responsecode.SERVICE_UNAVAILABLE,"Service is starting up" ))
- else:
- updateLock = self.directory.updateLock()
- yield updateLock.acquire()
- try:
- response = (yield maybeDeferred(super(DirectoryBackedAddressBookResource, self).renderHTTP, request))
-
- finally:
- yield updateLock.release()
-
- returnValue(response)
+ response = (yield maybeDeferred(super(DirectoryBackedAddressBookResource, self).renderHTTP, request))
+ returnValue(response)
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_addressbook_query.py 2012-03-12 21:23:40 UTC (rev 8843)
@@ -182,47 +182,20 @@
directoryAddressBookLock = None
try:
- if addrresource.isDirectoryBackedAddressBookCollection() and addrresource.directory.cacheQuery:
-
- directory = addrresource.directory
- if directory.liveQuery:
- # if liveQuery and cacheQuery, get vCards into the directory address book on disk
- directoryAddressBookLock, limited[0] = (yield directory.cacheVCardsForAddressBookQuery( filter, query, max_number_of_results[0] ) )
+ if not addrresource.isAddressBookCollection():
- elif directory.maxDSQueryRecords and directory.maxDSQueryRecords < max_number_of_results[0]:
- max_number_of_results[0] = directory.maxDSQueryRecords
-
-
- elif not addrresource.isAddressBookCollection():
-
#do UID lookup on last part of uri
resource_name = urllib.unquote(uri[uri.rfind("/") + 1:])
if resource_name.endswith(".vcf") and len(resource_name) > 4:
# see if parent is directory backed address book
parent = (yield addrresource.locateParent( request, uri ) )
-
- if parent.isDirectoryBackedAddressBookCollection() and parent.directory.cacheQuery:
-
- directory = parent.directory
- if directory.liveQuery:
- vCardFilter = carddavxml.Filter( *[carddavxml.PropertyFilter(
- carddavxml.TextMatch.fromString(resource_name[:-4]),
- name="UID", # attributes
- ),] )
- vCardFilter = addressbookqueryfilter.Filter(vCardFilter)
-
- directoryAddressBookLock, limited[0] = (yield directory.cacheVCardsForAddressBookQuery( vCardFilter, query, max_number_of_results[0] ) )
-
- elif directory.maxDSQueryRecords and directory.maxDSQueryRecords < max_number_of_results[0]:
- max_number_of_results[0] = directory.maxDSQueryRecords
-
-
+
# Check whether supplied resource is an address book or an address book object resource
if addrresource.isAddressBookCollection():
- if addrresource.isDirectoryBackedAddressBookCollection() and addrresource.directory.liveQuery and not addrresource.directory.cacheQuery:
+ if addrresource.isDirectoryBackedAddressBookCollection():
yield maybeDeferred( queryDirectoryBackedAddressBook, addrresource, filter )
else:
@@ -272,7 +245,7 @@
# see if parent is directory backed address book
parent = (yield addrresource.locateParent( request, uri ) )
- if parent.isDirectoryBackedAddressBookCollection() and parent.directory.liveQuery and not parent.directory.cacheQuery:
+ if parent.isDirectoryBackedAddressBookCollection():
vCardFilter = carddavxml.Filter( *[carddavxml.PropertyFilter(
carddavxml.TextMatch.fromString(resource_name[:-4]),
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_multiget_common.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_multiget_common.py 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/method/report_multiget_common.py 2012-03-12 21:23:40 UTC (rev 8843)
@@ -171,7 +171,7 @@
# Special for addressbooks
if collection_type == COLLECTION_TYPE_ADDRESSBOOK:
- if self.isDirectoryBackedAddressBookCollection() and self.directory.liveQuery:
+ if self.isDirectoryBackedAddressBookCollection():
result = (yield doDirectoryAddressBookResponse())
returnValue(result)
@@ -263,7 +263,7 @@
carddavxml.TextMatch.fromString(resource_name[:-4]),
name="UID", # attributes
))
- elif not self.directory.cacheQuery:
+ else:
responses.append(davxml.StatusResponse(href, davxml.Status.fromResponseCode(responsecode.NOT_FOUND)))
# exit if not valid
@@ -272,40 +272,29 @@
addressBookFilter = carddavxml.Filter( *vCardFilters )
addressBookFilter = addressbookqueryfilter.Filter(addressBookFilter)
- if self.directory.cacheQuery:
- # add vcards to directory address book and run "normal case" below
- limit = config.DirectoryAddressBook.MaxQueryResults
- directoryAddressBookLock, limited = (yield self.directory.cacheVCardsForAddressBookQuery(addressBookFilter, propertyreq, limit) )
- if limited:
- log.err("Too many results in multiget report: %d" % len(resources))
- raise HTTPError(ErrorResponse(
- responsecode.FORBIDDEN,
- (dav_namespace, "number-of-matches-within-limits"),
- "Too many results",
- ))
- else:
- #get vCards and filter
- limit = config.DirectoryAddressBook.MaxQueryResults
- vCardRecords, limited = (yield self.directory.vCardRecordsForAddressBookQuery( addressBookFilter, propertyreq, limit ))
- if limited:
- log.err("Too many results in multiget report: %d" % len(resources))
- raise HTTPError(ErrorResponse(
- responsecode.FORBIDDEN,
- (dav_namespace, "number-of-matches-within-limits"),
- "Too many results",
- ))
-
- for href in valid_hrefs:
- matchingRecord = None
- for vCardRecord in vCardRecords:
- if href == vCardRecord.hRef(): # might need to compare urls instead - also case sens ok?
- matchingRecord = vCardRecord
- break;
+
+ #get vCards and filter
+ limit = config.DirectoryAddressBook.MaxQueryResults
+ vCardRecords, limited = (yield self.directory.vCardRecordsForAddressBookQuery( addressBookFilter, propertyreq, limit ))
+ if limited:
+ log.err("Too many results in multiget report: %d" % len(resources))
+ raise HTTPError(ErrorResponse(
+ responsecode.FORBIDDEN,
+ (dav_namespace, "number-of-matches-within-limits"),
+ "Too many results",
+ ))
+
+ for href in valid_hrefs:
+ matchingRecord = None
+ for vCardRecord in vCardRecords:
+ if href == vCardRecord.hRef(): # might need to compare urls instead - also case sens ok?
+ matchingRecord = vCardRecord
+ break;
- if matchingRecord:
- yield report_common.responseForHref(request, responses, href, matchingRecord, propertiesForResource, propertyreq, vcard=matchingRecord.vCard())
- else:
- responses.append(davxml.StatusResponse(href, davxml.Status.fromResponseCode(responsecode.NOT_FOUND)))
+ if matchingRecord:
+ yield report_common.responseForHref(request, responses, href, matchingRecord, propertiesForResource, propertyreq, vcard=matchingRecord.vCard())
+ else:
+ responses.append(davxml.StatusResponse(href, davxml.Status.fromResponseCode(responsecode.NOT_FOUND)))
finally:
if directoryAddressBookLock:
yield directoryAddressBookLock.release()
Modified: CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/stdconfig.py 2012-03-12 20:06:49 UTC (rev 8842)
+++ CalendarServer/branches/users/gaya/ldapdirectorybacker/twistedcaldav/stdconfig.py 2012-03-12 21:23:40 UTC (rev 8843)
@@ -216,10 +216,7 @@
"queryDSLocal": False,
"ignoreSystemRecords": True,
"dsLocalCacheTimeout":30,
- "liveQuery": True,
"fakeETag": True,
- "cacheQuery": False,
- "cacheTimeout": 30,
"standardizeSyntheticUIDs": False,
"addDSAttrXProperties": False,
"appleInternalServer": False,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120312/6ae6a548/attachment-0001.html>
More information about the calendarserver-changes
mailing list