Hi there!  I'm a long-time Zope 2 user finally trying to do a demo project with 
off, congratulations to everyone developing Repoze!  You've really
cherry picked the best concepts from Zope and packaged them in a lean
modern framework.

My demo project was going along very well
until I tried to wire up some subscribers for repoze.folder events; my
subscriber callbacks don't seem to be firing.  After trying a few days
to figure out the problem, I think I need to ask for help.  I've tried
to come up with a small example to demonstrate the problem, and I'd be
very grateful for any help.  I feel like I'm missing something that
should be obvious.

I'm setting up a bfg_zodb project following
the instructions in the repoze tutorials.  (For what it's worth, I'm
using Python 2.5.4 on Ubuntu.)

$  virtualenv --no-site-packages folder_event_test
$  cd folder_event_test/
$  bin/easy_install -i http://dist.repoze.org/bfg/current/simple repoze.bfg
$  bin/easy_install -i http://dist.repoze.org/bfgsite/simple repoze.tm 
repoze.zodbconn repoze.who nose coverage
$  bin/easy_install repoze.catalog repoze.folder
$  bin/paster create -t bfg_zodb foo
$  cd foo
$  ../bin/python setup.py develop

My models.py contains a trivial subclass of Persistent and an application root 
subclasses Folder.  It also has a function subscriber_test() that
simply prints any events it receives.
import repoze.folder
import persistent

class Content(persistent.Persistent):
    def __init__(self):

class Site(repoze.folder.Folder):
    def __init__(self):

def appmaker(zodb_root):
    if not 'app_root' in zodb_root:
        app_root = Site()
        zodb_root['app_root'] = app_root
        import transaction
    return zodb_root['app_root']

def subscriber_test(event):
        print "subscriber_test event=%s" % repr(event)

My configure.zcml registers subscriber_test() for all events.
<configure xmlns="http://namespaces.repoze.org/bfg";>
  <include package="repoze.bfg.includes" />

Then I run bfgshell and add an instance of my Content class to the root object, 
which subclasses Folder.
$ ../bin/paster  --plugin=repoze.bfgbfgshell foo.inizodb
subscriber_test event=<repoze.bfg.events.WSGIApplicationCreatedEvent object at 
Python 2.5.4 (r254:67916, Jan 20 2010, 21:45:54) 
[GCC 4.3.3] on linux2
Type "help" for more information. "root" is the BFG app root object.
>>> root
<foo.models.Site object None at 0x1efc848>
>>> import foo.models
>>> root['test'] = foo.models.Content()
>>> root['test'].__name__
>>> root['test'].__parent__
<foo.models.Site object None at 0x19f19b0>
Note that subscriber_test() was called with a WSGIApplicationCreatedEvent as 
bfg started up.
I added a Content instance to the Site object, I expected to see my
subscriber_test() function called once with an ObjectWillBeAddedEvent
and again with an ObjectAddedEvent, but neither appeared to happen. 
Nothing was printed to stdout anyway.

Please let me know if you can help me out.
Thanks so much,

Repoze-dev mailing list

Reply via email to