[CalendarServer-changes] [7861] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 8 19:30:53 PDT 2011


Revision: 7861
          http://trac.macosforge.org/projects/calendarserver/changeset/7861
Author:   sagen at apple.com
Date:     2011-08-08 19:30:51 -0700 (Mon, 08 Aug 2011)
Log Message:
-----------
Adds ability to disable augments service

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/test/test_util.py
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/calendarserver/tools/util.py
    CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
    CalendarServer/trunk/twistedcaldav/directory/test/test_resources.py
    CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/twistedcaldav/test/test_upgrade.py

Modified: CalendarServer/trunk/calendarserver/tap/test/test_util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/test/test_util.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/calendarserver/tap/test/test_util.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -14,8 +14,9 @@
 # limitations under the License.
 ##
 
-from calendarserver.tap.util import computeProcessCount
+from calendarserver.tap.util import computeProcessCount, directoryFromConfig
 from twistedcaldav.test.util import TestCase
+from twistedcaldav.config import config
 
 class ProcessCountTestCase(TestCase):
 
@@ -47,3 +48,15 @@
                 expected,
                 computeProcessCount(min, perCPU, perGB, cpuCount=cpu, memSize=mem)
             )
+
+class UtilTestCase(TestCase):
+
+    def test_directoryFromConfig(self):
+        """
+        Ensure augments service is off by default
+        """
+        dir = directoryFromConfig(config)
+        for service in dir._recordTypes.values():
+            # all directory services belonging to the aggregate have
+            # augmentService set to None
+            self.assertEquals(getattr(service, "augmentService", None), None)

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -215,16 +215,17 @@
     #
     # Setup the Augment Service
     #
-    augmentClass = namedClass(config.AugmentService.type)
+    if config.AugmentService.type:
+        augmentClass = namedClass(config.AugmentService.type)
+        log.info("Configuring augment service of type: %s" % (augmentClass,))
+        try:
+            augmentService = augmentClass(**config.AugmentService.params)
+        except IOError:
+            log.error("Could not start augment service")
+            raise
+    else:
+        augmentService = None
 
-    log.info("Configuring augment service of type: %s" % (augmentClass,))
-
-    try:
-        augmentService = augmentClass(**config.AugmentService.params)
-    except IOError:
-        log.error("Could not start augment service")
-        raise
-
     #
     # Setup the group membership cacher
     #

Modified: CalendarServer/trunk/calendarserver/tools/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/util.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/calendarserver/tools/util.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -128,8 +128,11 @@
 
 
     # Load augment/proxy db classes now
-    augmentClass = namedClass(config.AugmentService.type)
-    augmentService = augmentClass(**config.AugmentService.params)
+    if config.AugmentService.type:
+        augmentClass = namedClass(config.AugmentService.type)
+        augmentService = augmentClass(**config.AugmentService.params)
+    else:
+        augmentService = None
 
     proxydbClass = namedClass(config.ProxyDBService.type)
     calendaruserproxy.ProxyDBService = proxydbClass(**config.ProxyDBService.params)

Modified: CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/twistedcaldav/directory/appleopendirectory.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -348,9 +348,10 @@
             # TODO: this needs to be deferred but for now we hard code
             # the deferred result because we know it is completing
             # immediately.
-            d = self.augmentService.getAugmentRecord(record.guid,
-                recordType)
-            d.addCallback(lambda x:record.addAugmentInformation(x))
+            if self.augmentService is not None:
+                d = self.augmentService.getAugmentRecord(record.guid,
+                    recordType)
+                d.addCallback(lambda x:record.addAugmentInformation(x))
             records.append(record)
 
         self.log_debug("ListRecords returning %d %s records" % (len(records),
@@ -590,9 +591,10 @@
                     # TODO: this needs to be deferred but for now we hard code
                     # the deferred result because we know it is completing
                     # immediately.
-                    d = self.augmentService.getAugmentRecord(record.guid,
-                        recordType)
-                    d.addCallback(lambda x:record.addAugmentInformation(x))
+                    if self.augmentService is not None:
+                        d = self.augmentService.getAugmentRecord(record.guid,
+                            recordType)
+                        d.addCallback(lambda x:record.addAugmentInformation(x))
 
                     yield record
 
@@ -897,9 +899,10 @@
             # Look up augment information
             # TODO: this needs to be deferred but for now we hard code the deferred result because
             # we know it is completing immediately.
-            d = self.augmentService.getAugmentRecord(record.guid,
-                recordType)
-            d.addCallback(lambda x:record.addAugmentInformation(x))
+            if self.augmentService is not None:
+                d = self.augmentService.getAugmentRecord(record.guid,
+                    recordType)
+                d.addCallback(lambda x:record.addAugmentInformation(x))
 
             # Override based on ResourceInfo
             if autoSchedule:

Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_resources.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_resources.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_resources.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -34,6 +34,7 @@
         config.ResourceService.Enabled = True
 
         xmlFile = os.path.join(testRoot, "augments.xml")
+        config.AugmentService.type = "twistedcaldav.directory.augment.AugmentXMLDB"
         config.AugmentService.params.xmlFiles = (xmlFile,)
 
 # Uh, what's this testing?

Modified: CalendarServer/trunk/twistedcaldav/directory/xmlfile.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/xmlfile.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/twistedcaldav/directory/xmlfile.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -172,9 +172,10 @@
                             shortNames    = tuple(xmlAccountRecord.shortNames),
                             xmlPrincipal  = xmlAccountRecord,
                         )
-                        d = self.augmentService.getAugmentRecord(record.guid,
-                            record.recordType)
-                        d.addCallback(lambda x:record.addAugmentInformation(x))
+                        if self.augmentService is not None:
+                            d = self.augmentService.getAugmentRecord(record.guid,
+                                record.recordType)
+                            d.addCallback(lambda x:record.addAugmentInformation(x))
 
                         self._addToIndex(record)
 

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -349,8 +349,8 @@
     #    Augments for the directory service records to add calendar specific attributes.
     #
     "AugmentService": {
-        "type": "twistedcaldav.directory.augment.AugmentXMLDB",
-        "params": DEFAULT_AUGMENT_PARAMS["twistedcaldav.directory.augment.AugmentXMLDB"],
+        "type": "",
+        "params" : {}
     },
 
     #

Modified: CalendarServer/trunk/twistedcaldav/test/test_upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2011-08-09 01:19:54 UTC (rev 7860)
+++ CalendarServer/trunk/twistedcaldav/test/test_upgrade.py	2011-08-09 02:30:51 UTC (rev 7861)
@@ -56,6 +56,7 @@
 
         xmlAugmentsFile = os.path.join(os.path.dirname(os.path.dirname(__file__)),
             "directory", "test", "augments.xml")
+        config.AugmentService.type = "twistedcaldav.directory.augment.AugmentXMLDB"
         config.AugmentService.params.xmlFiles = (xmlAugmentsFile,)
 
         resourceFile = os.path.join(os.path.dirname(os.path.dirname(__file__)),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110808/a287c76f/attachment-0001.html>


More information about the calendarserver-changes mailing list