[CalendarServer-changes] [14350] CalendarServer/trunk/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Tue Jan 27 20:11:47 PST 2015


Revision: 14350
          http://trac.calendarserver.org//changeset/14350
Author:   sagen at apple.com
Date:     2015-01-27 20:11:47 -0800 (Tue, 27 Jan 2015)
Log Message:
-----------
Upgrade resources.xml and augments.xml prior to using store/directory

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/stdconfig.py
    CalendarServer/trunk/twistedcaldav/upgrade.py

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-01-28 00:51:37 UTC (rev 14349)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-01-28 04:11:47 UTC (rev 14350)
@@ -15,30 +15,27 @@
 # limitations under the License.
 ##
 
+import copy
 import os
-import copy
+from plistlib import PlistParser  # @UnresolvedImport
 import re
 from socket import getfqdn, gethostbyname
 
+from calendarserver.push.util import getAPNTopicFromCertificate
+from twext.python.log import Logger, InvalidLogLevelError, LogLevel
+from twisted.python.filepath import FilePath
 from twisted.python.runtime import platform
-
-from plistlib import PlistParser  # @UnresolvedImport
-from twext.python.log import Logger, InvalidLogLevelError, LogLevel
-from txweb2.dav.resource import TwistedACLInheritable
-
-from txdav.xml import element as davxml
-
 from twistedcaldav import caldavxml, customxml, carddavxml, mkcolxml
+from twistedcaldav import ical
 from twistedcaldav.config import ConfigProvider, ConfigurationError, ConfigDict
 from twistedcaldav.config import config, mergeData, fullServerPath
-from twistedcaldav.util import getPasswordFromKeychain
+from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
 from twistedcaldav.util import KeychainAccessError, KeychainPasswordNotFound
 from twistedcaldav.util import computeProcessCount
-from twistedcaldav.datafilters.peruserdata import PerUserDataFilter
+from twistedcaldav.util import getPasswordFromKeychain
+from txdav.xml import element as davxml
+from txweb2.dav.resource import TwistedACLInheritable
 
-from calendarserver.push.util import getAPNTopicFromCertificate
-from twistedcaldav import ical
-
 log = Logger()
 
 
@@ -1363,8 +1360,18 @@
             if param not in DEFAULT_RESOURCE_PARAMS[configDict.ResourceService.type]:
                 del configDict.ResourceService.params[param]
 
+    # Upgrading resources.xml must be done prior to using the store/directory
+    if configDict.ResourceService.Enabled and configDict.ResourceService.type == "xml":
+        resourcesFileName = configDict.ResourceService.params.xmlFile
+        if resourcesFileName[0] not in ("/", "."):
+            resourcesFileName = os.path.join(configDict.DataRoot, resourcesFileName)
+        resourcesFilePath = FilePath(resourcesFileName)
+        if resourcesFilePath.exists():
+            from twistedcaldav.upgrade import upgradeResourcesXML
+            upgradeResourcesXML(resourcesFilePath)
 
 
+
 def _preUpdateDirectoryAddressBookBackingDirectoryService(configDict, items, reloading=False):
     #
     # Special handling for directory address book configs
@@ -1402,6 +1409,15 @@
                 log.warn("Parameter %s is not supported by service %s" % (param, configDict.AugmentService.type))
                 del configDict.AugmentService.params[param]
 
+    # Upgrading augments.xml must be done prior to using the store/directory
+    if configDict.AugmentService.type == "twistedcaldav.directory.augment.AugmentXMLDB":
+        for fileName in configDict.AugmentService.params.xmlFiles:
+            if fileName[0] not in ("/", "."):
+                fileName = os.path.join(configDict.DataRoot, fileName)
+            filePath = FilePath(fileName)
+            if filePath.exists():
+                from twistedcaldav.upgrade import upgradeAugmentsXML
+                upgradeAugmentsXML(filePath)
 
 
 def _updateACLs(configDict, reloading=False):
@@ -1714,6 +1730,7 @@
     _updateCompliance,
 )
 
+
 def _cleanup(configDict, defaultDict):
     cleanDict = copy.deepcopy(configDict)
 

Modified: CalendarServer/trunk/twistedcaldav/upgrade.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/upgrade.py	2015-01-28 00:51:37 UTC (rev 14349)
+++ CalendarServer/trunk/twistedcaldav/upgrade.py	2015-01-28 04:11:47 UTC (rev 14350)
@@ -758,22 +758,6 @@
 @inlineCallbacks
 def upgradeData(config, directory):
 
-    if config.ResourceService.Enabled:
-        resourcesFileName = config.ResourceService.params.xmlFile
-        if resourcesFileName[0] not in ("/", "."):
-            resourcesFileName = os.path.join(config.DataRoot, resourcesFileName)
-        resourcesFilePath = FilePath(resourcesFileName)
-        if resourcesFilePath.exists():
-            upgradeResourcesXML(resourcesFilePath)
-
-    if config.AugmentService.type == "twistedcaldav.directory.augment.AugmentXMLDB":
-        for fileName in config.AugmentService.params.xmlFiles:
-            if fileName[0] not in ("/", "."):
-                fileName = os.path.join(config.DataRoot, fileName)
-            filePath = FilePath(fileName)
-            if filePath.exists():
-                upgradeAugmentsXML(filePath)
-
     triggerPath = os.path.join(config.ServerRoot, TRIGGER_FILE)
     if os.path.exists(triggerPath):
         try:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150127/21c9df6a/attachment-0001.html>


More information about the calendarserver-changes mailing list