[z3-five] Plone Tool without acquisition

Chris Withers chris at simplistix.co.uk
Fri Feb 9 14:26:43 CET 2007


Philipp von Weitershausen wrote:
>>> Why would you want to get hold of the site root? Assuming that the 
>>> CMF tools are registered as local utilities, you should simply be 
>>> able to say:
>>>    from zope.component import getUtility
>>>    from Products.CMFPlone.interfaces import IPloneTool # verify this
>>>    plone_tool = getUtility(IPloneTool)
>>> Zope will automatically figure out that where it should get that tool 
>>> from (because it traversed over the site).
>>
>> Really? That feels a bit DWIM :-(
> 
> Yes.

Do you see that as a good or a bad thing?

>> I thought you had to pass in a context to get local utilities?
> 
> No. That's the point, the context is found during traversal and other 
> code doesn't have to be aware of the context. In fact, why would code 
> *care* where the utility is from? All it wants is a utility, be it local 
> or global.

Well, I'd imagine if you went to the trouble of registering local 
utilities, you did so for a reason?

If that's the case, then how do I make sure the right utilities are used 
when I'm traversing around several objects in different locations in the 
same piece of code?

I guess I'm interested in what couldn't as "traversed over" and how I 
can, if I need to, override where "Zope" thinks I've been traversing...

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the z3-five mailing list