[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration - meta.py:1.17 metameta.zcml:1.3 metametaConfigure.py:1.3 metametaConfigureForDocgen.py:1.3 metametaForDocgen.zcml:1.3

R. David Murray bitz@bitdance.com
Fri, 8 Nov 2002 14:08:28 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Configuration
In directory cvs.zope.org:/tmp/cvs-serv3605

Modified Files:
	meta.py metameta.zcml metametaConfigure.py 
	metametaConfigureForDocgen.py metametaForDocgen.zcml 
Log Message:
Simplify the configuration code by eliminating the top level directive
directive.  Now you always have to use 'directives' around your directive
subdirectives, but all the real (as opposed to test) zcml does so anyway,
so it does not seem to be any great burden.


=== Zope3/lib/python/Zope/Configuration/meta.py 1.16 => 1.17 ===
--- Zope3/lib/python/Zope/Configuration/meta.py:1.16	Wed Nov  6 17:30:22 2002
+++ Zope3/lib/python/Zope/Configuration/meta.py	Fri Nov  8 14:08:27 2002
@@ -297,17 +297,6 @@
         return ()
 
 
-def _registerDirective(_context, namespace, name, handler, attributes=''):
-    subs = register((namespace, name), _context.resolve(handler))
-    return subs, namespace
-
-def Directive(*args, **kw):
-    subs, namespace = _registerDirective(*args, **kw)
-    return Subdirective(subs, namespace=namespace)
-
-Directive.__implements__ = INonEmptyDirective
-
-
 class Subdirective:
     """This is the meta-meta-directive"""
     # 
@@ -348,14 +337,9 @@
     # (whose implementation is contained in this module) we can use
     # zcml to define any other directives needed for a given system.
     #
-    # The data structure created here is both recursive and incestuous.
-    # The recursive part allows for an unlimited number of levels
-    # of subdirective definition nesting.  The incestuous part is
-    # perhaps less legitimate, but seems logical since I can't think of
-    # a reason you would want the subdirective subdirective of the
-    # directive directive to do anything different from the subdirective
-    # subdirective of the directive subdirective of the directives
-    # directive.
+    # The data structure created here is recursive.  This allows for
+    # an unlimited number of levels of subdirective definition
+    # nesting.
     #
     # This initialziation is done in a function to facilitate support
     # the unittest CleanUp class.
@@ -365,7 +349,6 @@
     subdirkey = (zopens, 'subdirective')
     subs = {}
     subs[subdirkey] = (subs, 'subdirective')
-    _directives[(zopens, 'directive')] = (Directive, subs)
     directive = {(zopens, 'directive'): (subs, 'directive')}
     _directives[(zopens, 'directives')] = (DirectiveNamespace, directive)
 


=== Zope3/lib/python/Zope/Configuration/metameta.zcml 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Configuration/metameta.zcml:1.2	Wed Nov  6 17:30:22 2002
+++ Zope3/lib/python/Zope/Configuration/metameta.zcml	Fri Nov  8 14:08:27 2002
@@ -4,25 +4,12 @@
 
   <!-- Modify the bootstrap meta configuration directives
 
-  Note that the order we do this is important because we are
-  modifying the handlers we are using to process the text
-  that is triggering the modifications.
-
-  The first section here modifies the "directive" top-level
-  directive, which we aren't using in this file.  The second
-  section modifies the "directives" directive, which is the
-  directive used to trigger the modification.  So the handler
-  doesn't get changed until after it has already been called, and
-  all is well.
-
-  This file is perhaps a little bit too magical, since it depends
-  on the bootstrap registry's recursive data structure for
-  'subdirective' (the thing that allows subdirectives to be
-  defined to any desired nesting level).  But it's really pretty
-  straightforward:  we only need to modify the definition of
-  subdirective once, and that changes it both places it gets
-  used (directives/directive/subdirective and directive/subdirective)
-  and of course all the possible nested calls as well.
+  Note that we are modifying the handler we are using to
+  process the text that is triggering the modifications.
+  However, since modifications are non-destructive of
+  any pre-existing subdirective structure, this works.
+  Further, since the bootstrap namespace for subdirective
+  is recursive, we only have to modify subdirective once.
 
   The handler routines called out by the declarations in this
   file simply ignore the additional information provided by the
@@ -40,24 +27,6 @@
   -->
 
   <directive
-      name="directive"
-      attributes="namespace name handler attributes description"
-      handler="Zope.Configuration.metametaConfigure.Directive"
-  >
-    <subdirective
-        name="attribute"
-        attributes="name description required" />
-    <subdirective
-        name="subdirective"
-        attributes="name attributes namespace handler_method description"
-    >
-      <subdirective
-          name="attribute"
-          attributes="name description required" />
-    </subdirective>
-  </directive>
-
-  <directive
       name="directives"
       attributes="namespace name handler attributes description"
       handler="Zope.Configuration.metametaConfigure.DirectiveNamespace"
@@ -69,7 +38,14 @@
       <subdirective
           name="attribute"
           attributes="name description required" />
-      <!-- subdirective was already modified above -->
+      <subdirective
+          name="subdirective"
+          attributes="name attributes namespace handler_method description"
+      >
+        <subdirective
+            name="attribute"
+            attributes="name description required" />
+      </subdirective>
     </subdirective>
   </directive>
      


=== Zope3/lib/python/Zope/Configuration/metametaConfigure.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Configuration/metametaConfigure.py:1.2	Wed Nov  6 17:30:22 2002
+++ Zope3/lib/python/Zope/Configuration/metametaConfigure.py	Fri Nov  8 14:08:27 2002
@@ -16,7 +16,6 @@
 """
 from meta import DirectiveNamespace as bootstrapDirectiveNamespace
 from meta import Subdirective as bootstrapSubdirective
-from meta import _registerDirective
 from INonEmptyDirective import INonEmptyDirective
 from IEmptyDirective import IEmptyDirective
 from ISubdirectiveHandler import ISubdirectiveHandler
@@ -41,14 +40,6 @@
         self._useDescription(namespace, name, handler, description, subs)
         return self._Subdirective(subs, namespace=namespace, name=name)
     directive.__implements__ = INonEmptyDirective
-
-
-def Directive(_cotnext, namespace, name, handler, description='',
-        attributes=''):
-    subs, namespace = _registerDirective(_context, namespace, name, handler)
-    return self._Subdirective(subs, namespace=namespace, name=name)
-
-Directive.__implements__ = INonEmptyDirective
 
 
 class Subdirective(bootstrapSubdirective):


=== Zope3/lib/python/Zope/Configuration/metametaConfigureForDocgen.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Configuration/metametaConfigureForDocgen.py:1.2	Wed Nov  6 17:30:22 2002
+++ Zope3/lib/python/Zope/Configuration/metametaConfigureForDocgen.py	Fri Nov  8 14:08:27 2002
@@ -16,7 +16,6 @@
 """
 from metametaConfigure import DirectiveNamespace as baseDirectiveNamespace
 from metametaConfigure import Subdirective as baseSubdirective
-from metametaConfigure import Directive as baseDirective
 from INonEmptyDirective import INonEmptyDirective
 from ISubdirectiveHandler import ISubdirectiveHandler
 
@@ -78,14 +77,6 @@
 
     def _useDescription(self, namespace, name, handler, description, subs):
         _recordCommandMetadata(subs, description, handler)
-
-
-def Directive(_cotnext, namespace, name, handler, attributes='',
-        description=''):
-    subs = baseDirective(_context, namespace, name, handler, description)
-    _recordCommandMetadata(subs, description, handler)
-
-Directive.__implements__ = INonEmptyDirective
 
 
 class Subdirective(baseSubdirective):


=== Zope3/lib/python/Zope/Configuration/metametaForDocgen.zcml 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Configuration/metametaForDocgen.zcml:1.2	Wed Nov  6 17:30:22 2002
+++ Zope3/lib/python/Zope/Configuration/metametaForDocgen.zcml	Fri Nov  8 14:08:27 2002
@@ -1,10 +1,7 @@
 <zopeConfigure xmlns='http://namespaces.zope.org/zope'>
 
 <directives namespace="http://namespaces.zope.org/zope">
-  <!-- Install the docgen versions of the meta configuration handlers -->
-  <directive
-      name="directive"
-      handler="Zope.Configuration.metametaConfigureForDocgen.Directive" />
+  <!-- Install the docgen version of the meta configuration handler -->
   <directive
       name="directives"
       handler="Zope.Configuration.metametaConfigureForDocgen.DirectiveNamespace" />
@@ -15,103 +12,6 @@
   <!-- Add help text for the meta configuration directives -->
 
   <directive
-      name="directive"
-      handler="Zope.Configuration.metametaConfigureForDocgen.Directive"
-      description="Define a new configuration directive."
-  >
-    <attribute
-        name="namespace"
-        required="yes"
-        description="XML-style namespace identifier for the namespace
-            in which the directive being defined will reside." />
-    <attribute
-        name="name"
-        required="yes"
-        description="the name of the directive." />
-    <attribute
-        name="handler"
-        required="yes"
-        description="resolvable name of an IEmptyDirective or an
-            INonEmptyDirective that is to be called to handle
-            the directive." />
-    <attribute
-        name="description"
-        description="structured Text sentences that document the
-            purpose and function of the directive." />
-    <subdirective
-        name="attribute"
-        description="Define an attribute that may be specified on the
-            directive being defined"
-    >
-      <attribute
-          name="name"
-          required="yes"
-          description="the name of the attribute." />
-      <attribute
-          name="required"
-          required="no"
-          description="'yes', 'no', or missing.  'yes' indicates the attribute
-              being defined *must* be specified when the directive is used.
-              'no' means it can always be omitted.  If not specified, the
-              attribute may be part of a set of attributes one of which may
-              be required." />
-      <attribute
-          name="description"
-          description="structured Text sentences describing the purpose,
-            function, and allowed values of the attribute." />
-    </subdirective>
-    <subdirective
-        name="subdirective"
-        description="Define a subdirective that may be used inside
-            the enclosing directive in a configuration."
-    >
-      <attribute
-          name="name"
-          required="yes"
-          description="the name of the subdirective" />
-      <attribute
-          name="handler_method"
-          description="the name of an IEmptyDirective or an
-              INonEmptyDirective.  The name will be looked up on the
-              ISubDirectiveHandler returned by the handler for
-              the enclosing directive.  If not specified, the
-              subdirective name is used." />
-      <attribute
-          name="description"
-          description="structured Text sentences that document the
-              purpose and function of the subdirective." />
-      <attribute
-          name="namespace"
-          description="XML-style namespace identifier for the namespace
-              in which the directives being defined will reside.  If
-              specified it overrides the namespace inherited from
-              the enclosing directive." />
-      <subdirective
-          name="attribute"
-          description="Define an attribute that may be specified on the
-              subdirective being defined"
-      >
-        <attribute
-            name="name"
-            required="yes"
-            description="the name of the attribute." />
-        <attribute
-            name="required"
-            required="no"
-            description="'yes', 'no', or missing.  'yes' indicates the attribute
-                being defined *must* be specified when the directive is used.
-                'no' means it can always be omitted.  If not specified, the
-                attribute may be part of a set of attributes one of which may
-                be required." />
-        <attribute
-            name="description"
-            description="structured Text sentences describing the purpose,
-                function, and allowed values of the attribute." />
-      </subdirective>
-    </subdirective>
-  </directive>
-
-  <directive
       name="directives"
       handler="Zope.Configuration.metametaConfigureForDocgen.DirectiveNamespace"
       description="Define a set of new configuration directives within a
@@ -168,7 +68,39 @@
             description="structured Text sentences describing the purpose,
               function, and allowed values of the attribute." />
       </subdirective>
-      <!-- The descriptions for subdirective were already added above -->
+      <subdirective
+          name="subdirective"
+          description="Define a subdirective that may be used inside
+              the enclosing directive in a configuration."
+      >
+        <attribute
+            name="name"
+            required="yes"
+            description="the name of the subdirective" />
+        <attribute
+            name="handler_method"
+            description="the name of an IEmptyDirective or an
+                INonEmptyDirective.  The name will be looked up on the
+                ISubDirectiveHandler returned by the handler for
+                the enclosing directive.  If not specified, the
+                subdirective name is used." />
+        <attribute
+            name="description"
+            description="structured Text sentences that document the
+                purpose and function of the subdirective." />
+        <attribute
+            name="namespace"
+            description="XML-style namespace identifier for the namespace
+                in which the directives being defined will reside.  If
+                specified it overrides the namespace inherited from
+                the enclosing directive." />
+        <!--
+             We don't need to redefine the attribute subdirective of
+             the subdirective subdirective, because defining it in
+             directive's namespace defined it in the same (recursive)
+             namespace subdirective uses.
+        -->
+      </subdirective>
     </subdirective>
   </directive>