Hi there!  I'm a long-time Zope 2 user finally trying to do a demo project with 
Repoze.bfg.  
First
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 
that
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):
        persistent.Persistent.__init__(self)

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

def appmaker(zodb_root):
    if not 'app_root' in zodb_root:
        app_root = Site()
        zodb_root['app_root'] = app_root
        import transaction
        transaction.commit()
    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" />
  <subscriber
     for="zope.interface.Interface"
     handler=".models.subscriber_test"
     />
</configure>
--------------------------------------------------------------

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 
0x1efa590>
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__
u'test'
>>> root['test'].__parent__
<foo.models.Site object None at 0x19f19b0>
>>> 
--------------------------------------------------------------
Note that subscriber_test() was called with a WSGIApplicationCreatedEvent as 
bfg started up.
When
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,
Sam



      
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to