Ticket #136: config.py.patch
| File config.py.patch, 2.1 KB (added by callan@…, 3 years ago) |
|---|
-
config.py
20 20 import copy 21 21 22 22 from twisted.python import log 23 from twisted.python.reflect import namedClass 23 24 24 25 from twistedcaldav.py.plistlib import readPlist 25 26 … … 198 199 newParams = items["DirectoryService"].get("params", {}) 199 200 _mergeData(oldParams, newParams) 200 201 else: 202 # Lookup default parameters and insert them in the module 203 # variable if they exist. This process also ensures that the 204 # specified directory service class can be imported and that 205 # we have default parameters for the subsequent logic that 206 # follows. 207 try: 208 serviceClass = namedClass(dsType) 209 if hasattr(serviceClass, "defaultParams"): 210 serviceDefaultParams[dsType] = serviceClass.defaultParams 211 elif dsType not in serviceDefaultParams: 212 raise ConfigurationError( 213 "Default service parameters must be specified in " \ 214 "%s using the 'defaultParams' class variable or " \ 215 "via the 'defaultServiceParams' module variable " \ 216 "in twistedcaldav.config." % \ 217 dsType) 218 except (ImportError, AttributeError): 219 raise ConfigurationError("Unable to load directory service %s" % dsType) 220 201 221 if dsType in serviceDefaultParams: 202 222 self._data["DirectoryService"]["params"] = copy.deepcopy(serviceDefaultParams[dsType]) 203 223 else: 204 224 self._data["DirectoryService"]["params"] = {} 205 225 226 206 227 for param in items.get("DirectoryService", {}).get("params", {}): 207 228 if param not in serviceDefaultParams[dsType]: 208 229 raise ConfigurationError("Parameter %s is not supported by service %s" % (param, dsType))
