[Zope3-checkins] CVS: ZODB3/ZConfig - loader.py:1.18
Fred L. Drake, Jr.
fred@zope.com
Thu, 20 Feb 2003 10:30:47 -0500
Update of /cvs-repository/ZODB3/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv11402
Modified Files:
loader.py
Log Message:
API revision: An optional thrid argument to the loadConfig() and
loadConfigFile() can provide overrides from the command line.
=== ZODB3/ZConfig/loader.py 1.17 => 1.18 ===
--- ZODB3/ZConfig/loader.py:1.17 Wed Feb 19 16:30:14 2003
+++ ZODB3/ZConfig/loader.py Thu Feb 20 10:30:46 2003
@@ -38,11 +38,22 @@
def loadSchemaFile(file, url=None):
return SchemaLoader().loadFile(file, url)
-def loadConfig(schema, url):
- return ConfigLoader(schema).loadURL(url)
+def loadConfig(schema, url, overrides=()):
+ return _get_config_loader(schema, overrides).loadURL(url)
-def loadConfigFile(schema, file, url=None):
- return ConfigLoader(schema).loadFile(file, url)
+def loadConfigFile(schema, file, url=None, overrides=()):
+ return _get_config_loader(schema, overrides).loadFile(file, url)
+
+
+def _get_config_loader(schema, overrides):
+ if overrides:
+ from ZConfig import cmdline
+ loader = cmdline.ExtendedConfigLoader(schema)
+ for opt in overrides:
+ loader.addOption(opt)
+ else:
+ loader = ConfigLoader(schema)
+ return loader
class BaseLoader: