[ZPT] How to get a reference to the current object.

John Morton jwm@plain.co.nz
Tue, 11 Dec 2001 15:07:26 +1300


I have a macro that calls the methods of a particular type of object. In 
folder contexts it uses a sub-object like this: 

<span tal:define="file python:here.objectValues('My File')[0]">
<div metal:use-macro="here/filter/macros/filter_controls">Filters dialog</div>
</span>

(Let's ignore the fact that the code will barf if objectValues fails to 
return a sequence, for the moment).

In the context of the file itself, I still want to use the filter, but 
something like this:

<span tal:define="file here">
<div metal:use-macro="here/filter/macros/filter_controls">Filters dialog</div>
</span>

...ends up tying TALES into knots. The generated traceback looks like it 
chooses to opt out after two many levels of recursion, or similar. 

Is there an easy way to get a reference to the context object without using 
'here'?

John