[Zope-dev] Re: Renderable Base ZClass

Anthony Pfrunder s341625@student.uq.edu.au
Mon, 25 Oct 1999 09:07:20 +1000 (GMT+1000)


On Sun, 24 Oct 1999, Lalo Martins wrote:

[snip]
> More technical view, if anyone cares:
> 
> What Renderable does is basically define a __str__ method, so
> that we can control what is displayed when we do <dtml-var obj>
> (and obj is of a class derived from Renderable).
> 
> But __str__ is a pure-python feature, so it doesn't get a
> context (REQUEST etc).
> 
> Namely, we would really appreciate to be able to tell the name
> (url) of the object we're a method of :-)
> 

The _[] namespace may be of use here.  If there is a way to grab the _[]
namespace you should be able to access the REQUEST variable.

The other option is to hack _bobo_traverse (this is called to find the
method which is eventually called I think) so that it grabs the REQUEST
for the upcoming __str__ method. 

Cheers,

Anthony Pfrunder