[Grok-dev] five.grok.subscribe doesn't work

Vincent Fretin vincent.fretin at gmail.com
Thu Feb 12 04:29:15 EST 2009


Hi,

I try to use grok.subscribe to register my subscriber. I did the following:
viewlets.py:
-------------------------------------------------
from five import grok
from zope.lifecycleevent.interfaces import IObjectCreatedEvent
from Products.ATContentTypes.interface.document import IATDocument

grok.subscribe(IATDocument, IObjectCreatedEvent)
def documentCreated(obj, event):
    print "Document created", obj.id
-------------------------------------------------

configure.zcml:
-------------------------------------------------
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:grok="http://namespaces.zope.org/grok">
  <include package="five.grok" />
  <grok:grok package=".viewlets" />
</configure>
-------------------------------------------------

My subscribr is never executed.
I have viewlets in this module, and there are grokked, no problem.


The following works:
viewlets.py:
-------------------------------------------------
def documentCreated(obj, event):
    print "Document created", obj.id
-------------------------------------------------

configure.zcml:
-------------------------------------------------
<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:grok="http://namespaces.zope.org/grok">
  <include package="five.grok" />
  <grok:grok package=".viewlets" />
  <subscriber
      for="Products.ATContentTypes.interface.document.IATDocument
           zope.lifecycleevent.interfaces.IObjectCreatedEvent"
      handler=".viewlets.documentCreated"
  />
</configure>
-------------------------------------------------

Do I have missed something?

-- 
Vincent Fretin


More information about the Grok-dev mailing list