[Zope3-checkins] CVS: Zope/lib/python/ZConfig - SchemaContext.py:1.1.2.4 SchemaInterfaces.py:1.1.2.2

Chris McDonough chrism@zope.com
Mon, 25 Nov 2002 16:42:29 -0500


Update of /cvs-repository/Zope/lib/python/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv20928

Modified Files:
      Tag: chrism-install-branch
	SchemaContext.py SchemaInterfaces.py 
Log Message:
Document context interfaces and fix existing interfaces to match implementation.


=== Zope/lib/python/ZConfig/SchemaContext.py 1.1.2.3 => 1.1.2.4 ===
--- Zope/lib/python/ZConfig/SchemaContext.py:1.1.2.3	Mon Nov 25 13:02:45 2002
+++ Zope/lib/python/ZConfig/SchemaContext.py	Mon Nov 25 16:42:29 2002
@@ -17,10 +17,12 @@
 import os, urllib
 import SchemaParser
 from SchemaParser import SchemaError
+from SchemaInterfaces import ISchemaContext
 from Common import *
 import Context
 
 class SchemaContext(Context.Context):
+    __implements__ = ISchemaContext
     def load(self, url):
         if self.getConfig() is None:
             raise SchemaError, 'No schema set on context'


=== Zope/lib/python/ZConfig/SchemaInterfaces.py 1.1.2.1 => 1.1.2.2 ===
--- Zope/lib/python/ZConfig/SchemaInterfaces.py:1.1.2.1	Thu Nov 21 12:49:21 2002
+++ Zope/lib/python/ZConfig/SchemaInterfaces.py	Mon Nov 25 16:42:29 2002
@@ -2,11 +2,13 @@
 import Interface
 
 class IConfig(Interface.Interface):
-    def __init__(type, name, context):
+    def __init__(type, name, context, parent):
         """
         Initializes the configuration object.  The type is the
         configuration object type, the name is the configuration object
-        name, and the context is a SchemaContext object.
+        name, the context is a SchemaContext object, and the parent
+        is the parent object of the configuration object in
+        the configuration tree.
         """
         
     def getValue():
@@ -29,10 +31,7 @@
         """
         Returns a default value for the configuration object.
         If the configuration object does not have a default value (if it
-        is required), this method should not be overridden on a subclass,
-        as the base class definition will return a 'missing value'
-        marker that is understood by the rest of the configuration
-        machinery.
+        is required), this method should not be overridden on a subclass.
         """
 
 class IConfigKey(IConfig):
@@ -80,12 +79,12 @@
         sections found in the configuration file.
         """
 
-    def multidefault():
+    def default():
         """
         Returns a default value if no instances of a multiply-definable
-        key or section are found in the config file.  Do not override
-        this in a subclass if the multi-key or multi-section is required
-        (the base class definition will return a missing value marker).
+        key or section are found in the config file.  The method should
+        return a sequence.  Do not override this in a subclass if the
+        multi-key or multi-section is required.
         """
 
 class IConfigMultiKey(IConfigMulti, IConfigKey):
@@ -97,3 +96,27 @@
         'the ISection interface).'
         )
     pass
+
+class ISchemaContext(Interface.Interface):
+    def load(url):
+        """
+        Loads a configuration from a URL.  A schema must have been
+        loaded first or a SchemaError is raised.
+        """
+
+    def loadfile(file, url):
+        """
+        Loads a configuration from a file.   Has same semantics as load.
+        """
+
+    def loadschema(schema):
+        """
+        Loads a schema represented as a path to 'schema'.
+        """
+
+    def getConfig():
+        """
+        Returns the top-level object in the configuration tree
+        represented by the current schema.
+        """
+