On Wed, 2010-05-05 at 07:30 -0700, Sam Brauer wrote: > > From: Chris McDonough <chr...@plope.com> > > To: Sam Brauer <sampbra...@yahoo.com> > > Cc: email@example.com > > Sent: Tue, May 4, 2010 9:02:35 PM > > Subject: Re: [Repoze-dev] Folder event subscriber not called > > > > Hi Sam, > > > > Modify your run.py so that its app function calls "hook_zca" ala: > > > > def app(global_config, **settings): > > """ This function returns a WSGI application. > > > > It is usually called by the PasteDeploy framework during > > ``paster serve``. > > """ > > zodb_uri = settings.get('zodb_uri') > > zcml_file = settings.get('configure_zcml', 'configure.zcml') > > if zodb_uri is None: > > raise ValueError("No 'zodb_uri' in application configuration.") > > > > finder = PersistentApplicationFinder(zodb_uri, appmaker) > > def get_root(request): > > return finder(request.environ) > > config = Configurator(root_factory=get_root, settings=settings) > > config.begin() > > config.hook_zca() > > config.load_zcml(zcml_file) > > config.end() > > return config.make_wsgi_app() > > > > The repoze.folder code isn't dependent on BFG; it's actually general > > enough to be used in any ZODB application. Therefore it uses the > > "global" ZCA API to send events. When you call config.hook_zca(), this > > tells BFG to replace the "normal" lookup for a Zope global registry with > > a lookup which returns the ZCA registry that BFG uses. > > > > After I added this call, I tested your code, and saw your event sent to > > my console. > > > > See http://docs.repoze.org/bfg/1.2/narr/zca.html for more info. > > Chris, > That call to hook_zca() was indeed the missing piece. Thank you! > I think it would have taken me a very long time to have figured that out on > my own, and I can imagine that this might stump other new users as well.
Yes. > > May I suggest a couple of places in the documentation (which is > extraordinary, btw) where this might be mentioned? > It could be noted in the "Using Events" chapter of the docs > (http://docs.repoze.org/bfg/1.2/narr/events.html). > Also if you were to expand the example in the tutorial on using > repoze.catalog (http://docs.repoze.org/bfg/1.2/tutorials/catalog/index.html) > such that it included hooking up subscribers to index/unindex in response to > folder add/remove events, that would be another good place to mention it. I'd rather make a r.b.folder implementation that used the BFG API when sending events and demonstrate using that in a tutorial. Explaining what "hook_zca" does in general is hard; in context it's mostly impossible. - C _______________________________________________ Repoze-dev mailing list Repozefirstname.lastname@example.org http://lists.repoze.org/listinfo/repoze-dev