[Zope3-checkins] CVS: Packages/ZConfig - schema.py:1.1.2.20

Fred L. Drake, Jr. fred@zope.com
Mon, 16 Dec 2002 13:22:49 -0500


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

Modified Files:
      Tag: zconfig-schema-devel-branch
	schema.py 
Log Message:
- push_prefix():  Clean up the logic to be easier to read, and much
  more explicit.
- get_classname():  Move to a more reasonable location.


=== Packages/ZConfig/schema.py 1.1.2.19 => 1.1.2.20 ===
--- Packages/ZConfig/schema.py:1.1.2.19	Fri Dec 13 23:21:34 2002
+++ Packages/ZConfig/schema.py	Mon Dec 16 13:22:49 2002
@@ -99,12 +99,6 @@
 
     # schema loading logic
 
-    def get_classname(self, name):
-        if name.startswith(".") and self._prefixes:
-            return self._prefixes[-1] + name
-        else:
-            return name
-
     def get_handler(self, attrs):
         v = attrs.get("handler")
         if v is None:
@@ -113,11 +107,25 @@
             return self._basic_key(v)
 
     def push_prefix(self, attrs):
-        name = attrs.get("prefix", "")
-        prefix = self.get_classname(name)
-        if prefix[:1] == ".":
-            self.doSchemaError("prefix may not begin with '.'")
+        name = attrs.get("prefix")
+        if name:
+            if name.startswith(".") and self._prefixes:
+                prefix = self._prefixes[-1] + name
+            elif name.startswith("."):
+                self.doSchemaError("prefix may not begin with '.'")
+            else:
+                prefix = name
+        elif self._prefixes:
+            prefix = self._prefixes[-1]
+        else:
+            prefix = ''
         self._prefixes.append(prefix)
+
+    def get_classname(self, name):
+        if name.startswith("."):
+            return self._prefixes[-1] + name
+        else:
+            return name
 
     def get_datatype(self, attrs, attrkey, default):
         if attrs.has_key(attrkey):