[CalendarServer-changes] [4248] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Tue May 12 18:24:17 PDT 2009


Revision: 4248
          http://trac.macosforge.org/projects/calendarserver/changeset/4248
Author:   sagen at apple.com
Date:     2009-05-12 18:24:16 -0700 (Tue, 12 May 2009)
Log Message:
-----------
calendarserver_manage_principals will use memcached if it's available, and not complain if it isn't.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/principals.py
    CalendarServer/trunk/calendarserver/tools/util.py
    CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py

Modified: CalendarServer/trunk/calendarserver/tools/principals.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/principals.py	2009-05-13 01:17:44 UTC (rev 4247)
+++ CalendarServer/trunk/calendarserver/tools/principals.py	2009-05-13 01:24:16 UTC (rev 4248)
@@ -43,7 +43,7 @@
 from twistedcaldav.notify import installNotificationClient
 from twistedcaldav.static import CalendarHomeProvisioningFile
 
-from calendarserver.tools.util import UsageError, booleanArgument
+from calendarserver.tools.util import UsageError, booleanArgument, autoDisableMemcached
 from calendarserver.tools.util import loadConfig, getDirectory, dummyDirectoryRecord
 from calendarserver.provision.root import RootResource
 
@@ -178,6 +178,7 @@
     #
     try:
         loadConfig(configFileName)
+        autoDisableMemcached(config)
     except ConfigurationError, e:
         abort(e)
 

Modified: CalendarServer/trunk/calendarserver/tools/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/util.py	2009-05-13 01:17:44 UTC (rev 4247)
+++ CalendarServer/trunk/calendarserver/tools/util.py	2009-05-13 01:24:16 UTC (rev 4248)
@@ -27,6 +27,7 @@
 
 from twisted.python.reflect import namedClass
 
+import socket
 from twistedcaldav.config import config, defaultConfigFile, ConfigurationError
 from twistedcaldav.directory.directory import DirectoryService, DirectoryRecord
 
@@ -116,3 +117,24 @@
         return False
     else:
         raise ValueError("Not a boolean: %s" % (arg,))
+
+
+
+
+
+def autoDisableMemcached(config):
+    """
+    If memcached is not running, set config.Memcached.ClientEnabled to False
+    """
+
+    if not config.Memcached.ClientEnabled:
+        return
+
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+
+    try:
+        s.connect((config.Memcached.BindAddress, config.Memcached.Port))
+        s.close()
+
+    except socket.error:
+        config.Memcached.ClientEnabled = False

Modified: CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py	2009-05-13 01:17:44 UTC (rev 4247)
+++ CalendarServer/trunk/twistedcaldav/directory/cachingdirectory.py	2009-05-13 01:24:16 UTC (rev 4248)
@@ -75,8 +75,7 @@
     def addRecord(self, record, indexType, indexKey, useMemcache=True,
         neverExpire=False):
 
-        useMemcache == useMemcache and config.Memcached.ClientEnabled
-
+        useMemcache = useMemcache and config.Memcached.ClientEnabled
         if neverExpire:
             record.neverExpire()
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090512/c95a84b1/attachment.html>


More information about the calendarserver-changes mailing list