[CalendarServer-changes] [13478] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu May 15 11:43:58 PDT 2014


Revision: 13478
          http://trac.calendarserver.org//changeset/13478
Author:   sagen at apple.com
Date:     2014-05-15 11:43:58 -0700 (Thu, 15 May 2014)
Log Message:
-----------
Create augments.xml file(s) at startup, but also deal with them not being there if you're simply deleting an augment record.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/directory/augment.py
    CalendarServer/trunk/txdav/who/test/test_util.py
    CalendarServer/trunk/txdav/who/util.py

Modified: CalendarServer/trunk/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/augment.py	2014-05-15 16:09:15 UTC (rev 13477)
+++ CalendarServer/trunk/twistedcaldav/directory/augment.py	2014-05-15 18:43:58 UTC (rev 13478)
@@ -440,7 +440,11 @@
 
     def _doRemoveFromFile(self, xmlfile, uids):
 
-        _ignore_etree, augments_node = readXML(xmlfile)
+        try:
+            _ignore_etree, augments_node = readXML(xmlfile)
+        except IOError:
+            # If the file is missing, then removal is a no-op
+            return
 
         # Remove all UIDs present
         changed = False

Modified: CalendarServer/trunk/txdav/who/test/test_util.py
===================================================================
--- CalendarServer/trunk/txdav/who/test/test_util.py	2014-05-15 16:09:15 UTC (rev 13477)
+++ CalendarServer/trunk/txdav/who/test/test_util.py	2014-05-15 18:43:58 UTC (rev 13478)
@@ -62,15 +62,10 @@
         sourceAccounts = sourceDir.child("accounts.xml")
         accounts.setContent(sourceAccounts.getContent())
 
-        resources = destDir.child("resources.xml")
-        sourceResources = sourceDir.child("resources.xml")
-        resources.setContent(sourceResources.getContent())
+        # Note, don't create resources.xml nor augments.xml here,
+        # We'll test later on that they get created automatically.
 
-        augments = destDir.child("augments.xml")
-        sourceAugments = sourceDir.child("augments.xml")
-        augments.setContent(sourceAugments.getContent())
 
-
     @inlineCallbacks
     def test_directoryFromConfig(self):
 
@@ -114,6 +109,12 @@
         store = StubStore()
         service = directoryFromConfig(config, store=store)
 
+        # Make sure XML files were created
+        dataRoot = FilePath(self.dataRoot)
+        self.assertTrue(dataRoot.child("accounts.xml").exists())
+        self.assertTrue(dataRoot.child("resources.xml").exists())
+        self.assertTrue(dataRoot.child("augments.xml").exists())
+
         # Inspect the directory service structure
         self.assertTrue(isinstance(service, AugmentedDirectoryService))
         self.assertTrue(isinstance(service._directory, AggregateDirectoryService))

Modified: CalendarServer/trunk/txdav/who/util.py
===================================================================
--- CalendarServer/trunk/txdav/who/util.py	2014-05-15 16:09:15 UTC (rev 13477)
+++ CalendarServer/trunk/txdav/who/util.py	2014-05-15 18:43:58 UTC (rev 13478)
@@ -209,6 +209,12 @@
     # Setup the Augment Service
     #
     if augmentServiceInfo.type:
+        for augmentFile in augmentServiceInfo.params.xmlFiles:
+            augmentFile = fullServerPath(dataRoot, augmentFile)
+            augmentFilePath = FilePath(augmentFile)
+            if not augmentFilePath.exists():
+                augmentFilePath.setContent(DEFAULT_AUGMENT_CONTENT)
+
         augmentClass = namedClass(augmentServiceInfo.type)
         log.info(
             "Configuring augment service of type: {augmentClass}",
@@ -280,3 +286,8 @@
 
 <directory realm="Realm"/>
 """
+
+DEFAULT_AUGMENT_CONTENT = """<?xml version="1.0" encoding="utf-8"?>
+
+<augments/>
+"""
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140515/ab67a017/attachment-0001.html>


More information about the calendarserver-changes mailing list