[Zope3-Users] Re: ZODB - root and transaction

Stephan Richter srichter at cosmos.phy.tufts.edu
Thu Jun 1 14:09:43 EDT 2006


On Wednesday 05 April 2006 10:07, Reinhold Strobl wrote:
> I want in a utility class to get access with the current (!) database of
> the zope 3 application.
> In views, this is no problem, since I have the context variable, but this
> is not ture for utilities...

There are several possible solutions.

(a) Local utilities do know about the DB. zapi.getParent(utility)

(b) If you rely on the context, then your utility API should incorporate this 
in the methods, i.e. utility.method(context, ...)

(c) Use zope.app.component.hooks.getSite() you can get the current site.

I only find solution (b) desirable.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list