[Zope3-checkins] CVS: Packages/ZConfig - cfgparser.py:1.7 loader.py:1.14

Fred L. Drake, Jr. fred@zope.com
Tue, 14 Jan 2003 10:16:58 -0500


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

Modified Files:
	cfgparser.py loader.py 
Log Message:
Clean up imports to avoid most ordering dependencies.

=== Packages/ZConfig/cfgparser.py 1.6 => 1.7 ===
--- Packages/ZConfig/cfgparser.py:1.6	Thu Jan  9 11:34:43 2003
+++ Packages/ZConfig/cfgparser.py	Tue Jan 14 10:16:55 2003
@@ -13,9 +13,10 @@
 ##############################################################################
 """Configuration parser."""
 
-from ZConfig import ConfigurationError, ConfigurationSyntaxError
+import ZConfig
+import ZConfig.url
+
 from ZConfig.substitution import isname, substitute
-from ZConfig.url import urljoin
 
 try:
     True
@@ -95,7 +96,7 @@
         try:
             newsect = self.context.startSection(section, type, name,
                                                 delegatename)
-        except ConfigurationError, e:
+        except ZConfig.ConfigurationError, e:
             self.error(e[0])
 
         if isempty:
@@ -115,7 +116,7 @@
         try:
             self.context.endSection(
                 prevsection, type, name, delegatename, section)
-        except ConfigurationError, e:
+        except ZConfig.ConfigurationError, e:
             self.error(e[0])
         return prevsection
 
@@ -130,7 +131,7 @@
             value = substitute(value, self.defs)
         try:
             section.addValue(key, value, (self.lineno, None, self.url))
-        except ConfigurationError, e:
+        except ZConfig.ConfigurationError, e:
             self.error(e[0])
 
     def handle_directive(self, section, rest):
@@ -150,7 +151,7 @@
             assert 0, "unexpected directive for " + `"%" + rest`
 
     def handle_include(self, section, rest):
-        newurl = urljoin(self.url, rest)
+        newurl = ZConfig.url.urljoin(self.url, rest)
         self.context.includeConfiguration(section, newurl, self.defs)
 
     def handle_define(self, section, rest):
@@ -166,7 +167,7 @@
         self.defs[defname] = substitute(defvalue, self.defs)
 
     def error(self, message):
-        raise ConfigurationSyntaxError(message, self.url, self.lineno)
+        raise ZConfig.ConfigurationSyntaxError(message, self.url, self.lineno)
 
 
 import re


=== Packages/ZConfig/loader.py 1.13 => 1.14 ===
--- Packages/ZConfig/loader.py:1.13	Mon Jan 13 12:49:18 2003
+++ Packages/ZConfig/loader.py	Tue Jan 14 10:16:55 2003
@@ -19,10 +19,11 @@
 import urllib2
 
 import ZConfig
-
-from ZConfig import datatypes
-from ZConfig import matcher
-from ZConfig.url import urlnormalize, urldefrag, urljoin, urlsplit, urlunsplit
+import ZConfig.cfgparser
+import ZConfig.datatypes
+import ZConfig.matcher
+import ZConfig.schema
+import ZConfig.url
 
 try:
     True
@@ -83,7 +84,7 @@
     def normalizeURL(self, url):
         if os.path.exists(url):
             url = "file://" + urllib.pathname2url(os.path.abspath(url))
-        url, fragment = urldefrag(url)
+        url, fragment = ZConfig.url.urldefrag(url)
         if fragment:
             raise ZConfig.ConfigurationError(
                 "fragment identifiers are not supported")
@@ -101,7 +102,7 @@
 class SchemaLoader(BaseLoader):
     def __init__(self, registry=None):
         if registry is None:
-            registry = datatypes.Registry()
+            registry = ZConfig.datatypes.Registry()
         BaseLoader.__init__(self)
         self.registry = registry
         self._cache = {}
@@ -110,8 +111,8 @@
         if resource.url and self._cache.has_key(resource.url):
             schema = self._cache[resource.url]
         else:
-            from ZConfig.schema import parseResource
-            schema = parseResource(resource, self.registry, self)
+            schema = ZConfig.schema.parseResource(resource,
+                                                  self.registry, self)
             self._cache[resource.url] = schema
         return schema
 
@@ -155,9 +156,11 @@
 
     def loadResource(self, resource):
         self.handlers = []
-        sm = matcher.SchemaMatcher(self.schema, self.handlers)
+        sm = ZConfig.matcher.SchemaMatcher(self.schema, self.handlers)
         self._parse_resource(sm, resource)
-        return sm.finish(), CompositeHandler(self.handlers, self.schema)
+        result = sm.finish(), CompositeHandler(self.handlers, self.schema)
+        del self.handlers
+        return result
 
     # config parser support API
 
@@ -175,7 +178,7 @@
             raise ZConfig.ConfigurationError(
                 "%s is not an allowed name for %s sections"
                 % (`name`, `ci.sectiontype.name`))
-        return matcher.SectionMatcher(ci, t, name, self.handlers)
+        return ZConfig.matcher.SectionMatcher(ci, t, name, self.handlers)
 
     def endSection(self, parent, type, name, delegatename, matcher):
         assert not delegatename
@@ -189,8 +192,7 @@
     # internal helper
 
     def _parse_resource(self, matcher, resource, defines=None):
-        from ZConfig.cfgparser import ZConfigParser
-        parser = ZConfigParser(resource, self, defines)
+        parser = ZConfig.cfgparser.ZConfigParser(resource, self, defines)
         parser.parse(matcher)