[z3-five] Plone Tool without acquisition
Philipp von Weitershausen
philipp at weitershausen.de
Thu Feb 8 11:02:11 CET 2007
On 8 Feb 2007, at 09:35 , Chris Withers wrote:
> 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.
> 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.
More information about the z3-five
mailing list