[Grok-dev] Grok decorators: notably the grok.subscribe

Luciano Ramalho luciano at ramalho.org
Sun Sep 23 05:11:24 EDT 2007


Hey, João Paulo,

I've looked into what you reported and found the fix you suggested
harmless; it doesn't break any previous test, and I can't see a
problem with it.

So I  added a test to expose the issue you reported and fixed it in
trunk. All tests pass.

Thanks for that contribution, Jõao Paulo!

Cheers,

Luciano

--
PS. Here's the svn diff output:

Index: src/grok/_grok.py
===================================================================
--- src/grok/_grok.py   (revision 79845)
+++ src/grok/_grok.py   (working copy)
@@ -136,6 +136,7 @@
         if subscribers is None:
             frame.f_locals['__grok_subscribers__'] = subscribers = []
         subscribers.append((function, self.subscribed))
+        return function

 from zope.component._declaration import adapter as _adapter
 class adapter(_adapter):
Index: src/grok/tests/event/subscriber.py
===================================================================
--- src/grok/tests/event/subscriber.py  (revision 79845)
+++ src/grok/tests/event/subscriber.py  (working copy)
@@ -8,6 +8,12 @@
   ['Manfred']
   >>> mammoths2
   ['Manfred']
+
+The decorated event handling function can also be called directly:
+
+  >>> mammothAdded(Mammoth('Max'),None)
+  >>> mammoths
+  ['Manfred', 'Max']

 """
 import grok


More information about the Grok-dev mailing list