[Zope-Checkins] CVS: Zope3/lib/python/Zope/Event - metaConfigure.py:1.1.2.1.6.1

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


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

Modified Files:
      Tag: contextual-directives
	metaConfigure.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/Event/metaConfigure.py 1.1.2.1 => 1.1.2.1.6.1 ===
 
 from Zope.Configuration.Action import Action
-from Zope.Configuration.name import resolve
 
 from Zope.Event import subscribe as eventSubscribe
 
 counter = 0
 
-def subscribe(subscriber, event_types=None, filter=None):
+def subscribe(_context, subscriber, event_types=None, filter=None):
     global counter
     counter += 1
 
-    subscriber = resolve(subscriber)
+    subscriber = _context.resolve(subscriber)
 
     if event_types is None:
         event_types=(None,)
@@ -38,10 +37,10 @@
         for event_type_name in [element.strip()
                                 for element
                                 in event_type_names.split(',')]:
-            event_types.append(resolve(event_type_name))
+            event_types.append(_context.resolve(event_type_name))
                         
     if filter is not None:
-        filter = resolve(filter)
+        filter = _context.resolve(filter)
 
     return [
         Action(