[z3-five] Plone Tool without acquisition
yuppie
y.2007- at wcm-solutions.de
Thu Feb 8 11:06:18 CET 2007
Hi Philipp!
Philipp von Weitershausen wrote:
> Dennis Schulz wrote:
>>> - The right way to solve your problem would be using a local site
>>> manager. Even if your tools are not registered as utilities, you can
>>> get hold of the site root and therefor of the tool without using
>>> acquisition. Plone 3.0 might give you some hints how to set this up.
>> I am not familiar with the Plone 3 code.
>> Can anyone point me to an example where I can see how to set up a local
>> site manager?
>>
>> I registered
>>
>> <five:localsite
>> class="Products.CMFPlone.Portal.PloneSite" />
>>
>> What is the easiest way to get hold of the site root so I can use the
>> Plone tool without acquisition?
>
> 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).
You missed the start of this thread. We were not talking about a clean
solution that requires properly registered and acquisition wrapped tools.
We were talking about a hack for using tools in vocabularies without
acquisition context. Right now, in Zope 2.9, without the not yet
existing five.localsitemanager.
In Zope 2.10 I can use zope.app.component.hooks.getSite() to get the
acquisition wrapped site. Don't know what needs to be set up in Zope 2.9
to have this available.
Cheers,
Yuppie
More information about the z3-five
mailing list