[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI - IconDirective.py:1.1.2.2.6.1 TabsDirective.py:1.1.2.4.6.1 provideClass.py:1.1.2.11.4.1

Barry Warsaw barry@wooz.org
Thu, 21 Mar 2002 19:27:27 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI
In directory cvs.zope.org:/tmp/cvs-serv22971/lib/python/Zope/App/ZMI

Modified Files:
      Tag: contextual-directives
	IconDirective.py TabsDirective.py provideClass.py 
Log Message:
This is work to pass context to zcml directives, so that directives
know where they live.  This is inspired by some suggested changes to
the naming syntax that Stephan and I discussed with Jim.
Specifically, a leading dot, as in

    .JobBoardEx.JobList.

would signify a name relative to the current package, instead of
relative to ZopeProducts.  Also, we'd like to change the trailing dot
to a `+' for signifying "look-the-last-name-up-recursively-until-you-
can't-anymore".  E.g.:

    .JobBoardEx.JobList+

I'm committing this on a branch because it breaks the unit tests and
I'm not sure of the best way to fix the remaining 10 failures.  Jim
suggests that we commit these to the branch so that he can work on
them too.


=== Zope3/lib/python/Zope/App/ZMI/IconDirective.py 1.1.2.2 => 1.1.2.2.6.1 ===
 """
 
-def IconDirective(for_, file):
+def IconDirective(_context, for_, file):
     #stub
     return ()


=== Zope3/lib/python/Zope/App/ZMI/TabsDirective.py 1.1.2.4 => 1.1.2.4.6.1 ===
 
 from Zope.Configuration.Action import Action
-from Zope.Configuration.name import resolve
 
 #from ComponentArchitecture import getService
 from ZMIViewService import ZMIViews
@@ -28,10 +27,10 @@
 
     __implements__ = INonEmptyDirective
 
-    def __init__(self, for_):
-        self._for_ = resolve(for_)
+    def __init__(self, _context, for_):
+        self._for_ = _context.resolve(for_)
 
-    def tab(self, label, action, filter='python: 1'):
+    def tab(self, _context, label, action, filter='python: 1'):
         return [
             Action(
                discriminator =('tab', self._for_, label),


=== Zope3/lib/python/Zope/App/ZMI/provideClass.py 1.1.2.11 => 1.1.2.11.4.1 ===
 from Zope.ComponentArchitecture.IFactory import IFactory
 from Zope.ComponentArchitecture import provideFactory
-from Zope.Configuration.name import resolve
 import Addable
 
 class ClassFactory:
@@ -31,7 +30,7 @@
         return self._class()
 
 
-def provideClass(registry, qualified_name, _class, permission,
+def provideClass(_context, registry, qualified_name, _class, permission,
                  title, description=''):
     """Provide simple class setup
 
@@ -47,18 +46,18 @@
     provideFactory(qualified_name, factory)
     registry.provideAddable(qualified_name, title, description)
 
-def ServiceClassDir(name, permission_id, title, description=''):
+def ServiceClassDir(_context, name, permission_id, title, description=''):
     return ((name,
              provideClass,
-             (Addable.ServiceAddables, name, resolve(name),
+             (Addable.ServiceAddables, name, _context.resolve(name),
               permission_id, title, description)
              ),)
 
 
-def ContentClassDir(name, permission_id, title, description=''):
+def ContentClassDir(_context, name, permission_id, title, description=''):
     return ((name,
              provideClass,
-             (Addable.ContentAddables, name, resolve(name),
+             (Addable.ContentAddables, name, _context.resolve(name),
               permission_id, title, description)
              ),)