[Zope3-checkins] CVS: Packages/ZConfig - Context.py:1.20 cfgparser.py:1.5 loader.py:1.8

Fred L. Drake, Jr. fred@zope.com
Thu, 9 Jan 2003 11:06:08 -0500


Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv2126

Modified Files:
	Context.py cfgparser.py loader.py 
Log Message:
Share the %define namespace with %inclduded resources.
Added new test to make sure this works, and ensure it does not get broken
later.


=== Packages/ZConfig/Context.py 1.19 => 1.20 ===
--- Packages/ZConfig/Context.py:1.19	Fri Jan  3 17:22:41 2003
+++ Packages/ZConfig/Context.py	Thu Jan  9 11:05:34 2003
@@ -40,9 +40,9 @@
         # overriding the Context.getDelegateType() method.
         return type.lower()
 
-    def parse(self, resource, section):
+    def parse(self, resource, section, defines=None):
         from ZConfig.cfgparser import ZConfigParser
-        ZConfigParser(resource, self).parse(section)
+        ZConfigParser(resource, self, defines).parse(section)
 
     def loadResource(self, resource):
         top = self.createToplevelSection(resource.url)
@@ -53,10 +53,10 @@
 
     # interface for parser
 
-    def includeConfiguration(self, section, url):
+    def includeConfiguration(self, section, url, defines):
         r = self.openResource(url)
         try:
-            self.parse(r, section)
+            self.parse(r, section, defines)
         finally:
             r.close()
 


=== Packages/ZConfig/cfgparser.py 1.4 => 1.5 ===
--- Packages/ZConfig/cfgparser.py:1.4	Thu Jan  9 10:34:14 2003
+++ Packages/ZConfig/cfgparser.py	Thu Jan  9 11:05:34 2003
@@ -25,14 +25,16 @@
 
 
 class ZConfigParser:
-    def __init__(self, resource, context):
+    def __init__(self, resource, context, defines=None):
         self.resource = resource
         self.context = context
         self.file = resource.file
         self.url = resource.url
         self.lineno = 0
         self.stack = []   # [(type, name, delegatename, prevmatcher), ...]
-        self.defs = {}
+        if defines is None:
+            defines = {}
+        self.defs = defines
 
     def nextline(self):
         line = self.file.readline()
@@ -145,7 +147,7 @@
 
     def handle_include(self, section, rest):
         newurl = urljoin(self.url, rest)
-        self.context.includeConfiguration(section, newurl)
+        self.context.includeConfiguration(section, newurl, self.defs)
 
     def handle_define(self, section, rest):
         parts = rest.split(None, 1)


=== Packages/ZConfig/loader.py 1.7 => 1.8 ===
--- Packages/ZConfig/loader.py:1.7	Thu Jan  9 00:42:28 2003
+++ Packages/ZConfig/loader.py	Thu Jan  9 11:05:34 2003
@@ -203,15 +203,15 @@
         sectvalue = matcher.finish()
         parent.addSection(type, name, sectvalue)
 
-    def includeConfiguration(self, section, url):
+    def includeConfiguration(self, section, url, defines):
         r = self.openResource(url)
-        self._parse_resource(section, r)
+        self._parse_resource(section, r, defines)
 
     # internal helper
 
-    def _parse_resource(self, matcher, resource):
+    def _parse_resource(self, matcher, resource, defines=None):
         from ZConfig.cfgparser import ZConfigParser
-        parser = ZConfigParser(resource, self)
+        parser = ZConfigParser(resource, self, defines)
         parser.parse(matcher)