[z3-five] context-based utility lookup
Chris Withers
chris at simplistix.co.uk
Tue Feb 13 09:14:49 CET 2007
Philipp von Weitershausen wrote:
>> Indeed, but can you override the context that gets used to figure out
>> what utility gets picked up?
>
> Yes, you can always pass in a context explicitly in which case the
> closest site to that context will be used for the lookup.
Good stuff :-)
Out of curiosity, is it acquisition or __parent__ that's used to find
the "closest" site?
> Actually, the publication is quite agnostic of sites, fortunately. All
> the publication does is send out an IBeforeTraverseEvent for each object
> it is about to traverse. zope.app.component has a subscriber for that
> event on ISites that "remembers" the site in a thread local.
Hmm, that brings me to another minor bug bear: I hadto step through the
event process a week or so ago in pdb and was pretty horrified as to how
many function calls were involved from the time event.notify() got
called to when my event subscriber code was actually called. Not only
does it make pdb'ing a pain, but I also wonder how much of a performance
hurt that's going to be in a high volume application with a lot of
events being fired?
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the z3-five
mailing list