[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration - xmlconfig.py:1.6
Steve Alexander
steve@cat-box.net
Sun, 23 Jun 2002 12:20:22 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Configuration
In directory cvs.zope.org:/tmp/cvs-serv932/lib/python/Zope/Configuration
Modified Files:
xmlconfig.py
Log Message:
fixed up zcml include if you don't specify a package, and the including
zcml file doesn't supply a package either, transitively repeated.
There's a test for this now too!
=== Zope3/lib/python/Zope/Configuration/xmlconfig.py 1.5 => 1.6 ===
from Exceptions import ConfigurationError
+# marker used in Context class and XMLConfig class to indicate
+# that a particular zcml file was given no "package" attribute
+# when included, and the same went for all of its parents.
+_NO_MODULE_GIVEN = object()
+
class ZopeXMLConfigurationError(ConfigurationError):
"Zope XML Configuration error"
@@ -46,8 +51,7 @@
self.mess = mess
def __str__(self):
- return 'File "%s", line %s, column %s\n\t%s' % (
- self.sid, self.lno, self.cno, self.mess)
+ return 'File "%s", line %s, column %s\n\t%s' % ( self.sid, self.lno, self.cno, self.mess)
class ConfigurationExecutionError(ZopeXMLConfigurationError):
"""An error occurred during execution of a configuration action
@@ -170,9 +174,9 @@
""" % ((self.des,) + self.l1 + self.l2)
class Context:
- def __init__(self, stack, module=None):
+ def __init__(self, stack, module):
self.__stackcopy = tuple(stack)
- if module is None:
+ if module is _NO_MODULE_GIVEN:
self.__package = None
elif module is None:
self.__package = 'ZopeProducts'
@@ -252,11 +256,12 @@
r.append(" at line %s column %s of %s" % loc)
return "\n".join(r)
-
+
+
class XMLConfig:
- def __init__(self, file_name, module=None):
- if module is not None:
+ def __init__(self, file_name, module=_NO_MODULE_GIVEN):
+ if module is not None and module is not _NO_MODULE_GIVEN:
module_dir = os.path.split(module.__file__)[0]
file_name = os.path.join(module_dir, file_name)