[Product-Developers] Re: Viewlet variables in scope
Maurits van Rees
m.van.rees at zestsoftware.nl
Mon Oct 6 08:39:15 UTC 2008
Hedley Roos, on 2008-10-05:
> I chose a bad example with portal_url :(
>
> Let's say there is some variable "foo" in the 'outer' template. My
> viewlet has no knowledge of how to compute foo, but it knows it exists
> by my own convention.
>
> The only way for the viewlet to get to foo is by inspecting its scope
> (which I don't know how to do), or by some horrid way such as the
> outer template dropping the value foo onto the request with a
><tal:dummy define="dummy request.set('foo', 'bar')"/>
The easiest way is to make foo a property of your browser view. The
view is passed into the __init__ of your viewlet, so you can access foo
there.
There is another possibility with
zope.contentprovider.interfaces.ITALNamespaceData. Look around in
Products/eXtremeManagement/browser/viewlets/interfaces.py for some
examples. But in my experience that approach quickly gets ugly when
you intend to refresh that viewlet with KSS.
--
Maurits van Rees | http://maurits.vanrees.org/
Work | http://zestsoftware.nl/
"This is your day, don't let them take it away." [Barlow Girl]
More information about the Product-Developers
mailing list