[Zodb-checkins] CVS: Zope/lib/python/ZConfig -
datatypes.py:1.13.36.1 loader.py:1.18.44.1 schema.py:1.20.22.1
Chris McDonough
chrism at zope.com
Mon Jul 21 13:39:03 EDT 2003
Update of /cvs-repository/Zope/lib/python/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv17213/lib/python/ZConfig
Modified Files:
Tag: Zope-2_7-branch
datatypes.py loader.py schema.py
Log Message:
Merge changes from HEAD since the release of Zope 2.7a1 into the Zope-2_7-branch in preparation for release of Zope 2.7b1.
=== Zope/lib/python/ZConfig/datatypes.py 1.13 => 1.13.36.1 ===
--- Zope/lib/python/ZConfig/datatypes.py:1.13 Mon Mar 24 15:52:39 2003
+++ Zope/lib/python/ZConfig/datatypes.py Mon Jul 21 12:36:51 2003
@@ -111,14 +111,13 @@
RegularExpressionConversion.__init__(self, "[_a-zA-Z][_a-zA-Z0-9]*")
-if sys.version[:3] < "2.3":
- def integer(value):
- try:
- return int(value)
- except ValueError:
- return long(value)
-else:
- integer = int
+def integer(value):
+ try:
+ return int(value)
+ except ValueError:
+ return long(value)
+ except OverflowError:
+ return long(value)
def null_conversion(value):
@@ -209,10 +208,10 @@
raise ValueError, '%s is not an existing file' % v
def existing_dirpath(v):
- if not os.path.split(v)[0]:
- # relative pathname
- return v
dir = os.path.dirname(v)
+ if not dir:
+ # relative pathname with no directory component
+ return v
if os.path.isdir(dir):
return v
raise ValueError, ('The directory named as part of the path %s '
=== Zope/lib/python/ZConfig/loader.py 1.18 => 1.18.44.1 ===
--- Zope/lib/python/ZConfig/loader.py:1.18 Thu Feb 20 10:30:46 2003
+++ Zope/lib/python/ZConfig/loader.py Mon Jul 21 12:36:51 2003
@@ -137,7 +137,7 @@
# schema parser support API
- def schemaComponentInfo(self, package):
+ def schemaComponentSource(self, package, file):
parts = package.split(".")
if not parts:
raise ZConfig.SchemaError(
@@ -146,23 +146,16 @@
# '' somewhere in the package spec; still illegal
raise ZConfig.SchemaError(
"illegal schema component name: " + `package`)
+ file = file or "component.xml"
for dir in sys.path:
dirname = os.path.join(os.path.abspath(dir), *parts)
- fn = os.path.join(dirname, "component.xml")
+ fn = os.path.join(dirname, file)
if os.path.exists(fn):
break
else:
raise ZConfig.SchemaError(
"schema component not found: " + `package`)
- url = "file://" + urllib.pathname2url(fn)
- extensions = []
- for fn in os.listdir(dirname):
- if fn == "component.xml":
- continue
- path = os.path.join(dirname, fn, "extension.xml")
- if os.path.exists(path):
- extensions.append("file://" + urllib.pathname2url(path))
- return url, extensions
+ return "file://" + urllib.pathname2url(fn)
class ConfigLoader(BaseLoader):
@@ -186,7 +179,8 @@
def startSection(self, parent, type, name, delegatename):
if delegatename:
- raise NotImpementedError("section delegation is not yet supported")
+ raise NotImpementedError(
+ "section delegation is not yet supported")
t = self.schema.gettype(type)
if t.isabstract():
raise ZConfig.ConfigurationError(
=== Zope/lib/python/ZConfig/schema.py 1.20 => 1.20.22.1 ===
--- Zope/lib/python/ZConfig/schema.py:1.20 Thu May 1 15:34:57 2003
+++ Zope/lib/python/ZConfig/schema.py Mon Jul 21 12:36:51 2003
@@ -13,6 +13,7 @@
##############################################################################
"""Parser for ZConfig schemas."""
+import os
import xml.sax
import ZConfig
@@ -279,44 +280,39 @@
def start_import(self, attrs):
src = attrs.get("src", "").strip()
pkg = attrs.get("package", "").strip()
+ file = attrs.get("file", "").strip()
if not (src or pkg):
self.error("import must specify either src or package")
if src and pkg:
self.error("import may only specify one of src or package")
if src:
+ if file:
+ self.error("import may not specify file and src")
src = url.urljoin(self._url, src)
src, fragment = url.urldefrag(src)
if fragment:
- self.error("import src many not include a fragment identifier")
+ self.error("import src many not include"
+ " a fragment identifier")
schema = self._loader.loadURL(src)
for n in schema.gettypenames():
self._schema.addtype(schema.gettype(n))
- elif self._components.has_key(pkg):
- # already loaded, or in progress
- pass
else:
- pi = self._loader.schemaComponentInfo(pkg)
- if not pi:
- self.error("could not locate schema component " + `pkg`)
- self._components[pkg] = pi
- self.loadComponent(pi)
-
- def loadComponent(self, info):
- base, extensions = info
- r = self._loader.openResource(base)
- parser = ComponentParser(self._registry, self._loader, base,
+ if os.path.dirname(file):
+ self.error("file may not include a directory part")
+ src = self._loader.schemaComponentSource(pkg, file)
+ if not self._components.has_key(src):
+ self._components[pkg] = src
+ self.loadComponent(src)
+
+ def loadComponent(self, src):
+ r = self._loader.openResource(src)
+ parser = ComponentParser(self._registry, self._loader, src,
self._schema)
parser._components = self._components
try:
xml.sax.parse(r.file, parser)
finally:
r.close()
- for ext in extensions:
- r = self._loader.openResource(ext)
- try:
- parser.loadExtension(r)
- finally:
- r.close()
def end_import(self):
pass
@@ -525,23 +521,4 @@
self.push_prefix(attrs)
def end_component(self):
- self.pop_prefix()
-
- def loadExtension(self, resource):
- parser = ExtensionParser(self._registry, self._loader, resource.url,
- self._parent, self._localtypes)
- parser._components = self._components
- xml.sax.parse(resource.file, parser)
-
-
-class ExtensionParser(BaseComponentParser):
-
- _handled_tags = BaseComponentParser._handled_tags + ("extension",)
- _top_level = "extension"
-
- def start_extension(self, attrs):
- self._schema = self._parent
- self.push_prefix(attrs)
-
- def end_extension(self):
self.pop_prefix()
More information about the Zodb-checkins
mailing list