[Zope-Checkins] CVS: Packages/ZConfig - Config.py:1.6 Context.py:1.8 Substitution.py:1.2
Fred L. Drake, Jr.
fred@zope.com
Thu, 7 Nov 2002 13:54:39 -0500
Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv32398
Modified Files:
Config.py Context.py Substitution.py
Log Message:
During substitution, names are looked up from the container of a section if
they are not present in the section itself.
=== Packages/ZConfig/Config.py 1.5 => 1.6 ===
--- Packages/ZConfig/Config.py:1.5 Thu Nov 7 11:22:14 2002
+++ Packages/ZConfig/Config.py Thu Nov 7 13:54:39 2002
@@ -3,7 +3,8 @@
from Common import *
class Configuration:
- def __init__(self, type, name, url):
+ def __init__(self, container, type, name, url):
+ self.container = container
self.type = type
self.name = name or None
self.delegate = None
@@ -201,9 +202,9 @@
class ImportingConfiguration(Configuration):
- def __init__(self, *args):
+ def __init__(self, url):
self._imports = []
- Configuration.__init__(self, *args)
+ Configuration.__init__(self, None, None, None, url)
def addImport(self, section):
self._imports.append(section)
=== Packages/ZConfig/Context.py 1.7 => 1.8 ===
--- Packages/ZConfig/Context.py:1.7 Thu Nov 7 13:34:50 2002
+++ Packages/ZConfig/Context.py Thu Nov 7 13:54:39 2002
@@ -22,15 +22,15 @@
# subclass-support API
def createImportedSection(self, section, url):
- return ImportingConfiguration(None, None, url)
+ return ImportingConfiguration(url)
def createNestedSection(self, section, type, name, delegatename):
if name:
name = name.lower()
- return Configuration(type.lower(), name, section.url)
+ return Configuration(section, type.lower(), name, section.url)
def createToplevelSection(self, url):
- return ImportingConfiguration(None, None, url)
+ return ImportingConfiguration(url)
def getDelegateType(self, type):
# Applications must provide delegation typing information by
=== Packages/ZConfig/Substitution.py 1.1 => 1.2 ===
--- Packages/ZConfig/Substitution.py:1.1 Thu Nov 7 10:29:14 2002
+++ Packages/ZConfig/Substitution.py Thu Nov 7 13:54:39 2002
@@ -75,7 +75,16 @@
if rest[length:length+1] != "}":
raise SubstitutionSyntaxError(
"'${%s' not followed by '}'" % name, context)
- v = section.get(name, "")
+ v = section.get(name)
+ if v is None:
+ parent = section.container
+ while parent is not None:
+ v = parent.get(name)
+ if v is not None:
+ break
+ parent = parent.container
+ else:
+ v = ""
if "$" in v and context:
if name in context:
raise SubstitutionRecursionError(name, context)