[Zope-CVS] CVS: Products/Ape/lib/apelib/config - apeconf.py:1.1.2.4 common.py:1.1.2.2
Shane Hathaway
shane@zope.com
Tue, 8 Jul 2003 22:11:15 -0400
Update of /cvs-repository/Products/Ape/lib/apelib/config
In directory cvs.zope.org:/tmp/cvs-serv7805/lib/apelib/config
Modified Files:
Tag: ape-newconf-branch
apeconf.py common.py
Log Message:
Consolidated Zope 2 mapper configuration in a single module.
Also made Ape look for apeconf.xml files in all products, renamed the
root Zope 2 mapper to simply "root", and made variants extend the
default configuration implicitly.
=== Products/Ape/lib/apelib/config/apeconf.py 1.1.2.3 => 1.1.2.4 ===
--- Products/Ape/lib/apelib/config/apeconf.py:1.1.2.3 Tue Jul 8 00:09:33 2003
+++ Products/Ape/lib/apelib/config/apeconf.py Tue Jul 8 22:10:41 2003
@@ -475,17 +475,19 @@
self.classifier.setOption(name, option, value)
-def makeComponentSystem(filenames, vnames=('',)):
- """Returns an Ape component system.
+def wireMapper(filenames, vname='', mapper_name='root'):
+ """Returns an Ape mapper built according to the configuration files.
"""
handlers = getElementHandlers()
reader = DirectiveReader(handlers)
for fn in filenames:
reader.read(fn)
- directives = reader.getDirectives(vnames)
+ directives = reader.getDirectives(vname)
cs = ComponentSystem(directives)
cs.addComponentType('mapper', MapperAssembler)
for comptype in ('serializer', 'gateway', 'classifier', 'keygen'):
cs.addComponentType(comptype, BasicComponentAssembler)
- return cs
+ mapper = cs.get('mapper', mapper_name)
+ mapper.checkConfiguration(path=mapper_name)
+ return mapper
=== Products/Ape/lib/apelib/config/common.py 1.1.2.1 => 1.1.2.2 ===
--- Products/Ape/lib/apelib/config/common.py:1.1.2.1 Mon Jul 7 18:59:13 2003
+++ Products/Ape/lib/apelib/config/common.py Tue Jul 8 22:10:41 2003
@@ -128,12 +128,20 @@
else:
info[vname] = d
- def getDirectives(self, vnames=('',)):
+ def getDirectives(self, vname=''):
res = []
+ # Note that although there isn't a way to declare that a
+ # variant extends another variant, all variants should derive
+ # from the default anyway, so we don't need the extension
+ # mechanism yet.
+ if not vname:
+ vnames = ('',)
+ else:
+ vnames = (vname, '')
for key, info in self.directives.items():
- for vname in vnames:
- if info.has_key(vname):
- res.append(info[vname])
+ for vn in vnames:
+ if info.has_key(vn):
+ res.append(info[vn])
break # Go to next directive
return res