[Zope] dtml access to "container" within zclass

Ra ra@burningman.com
Fri, 16 Aug 2002 17:11:56 -0700


hi all,

is there any way to gain access to an instance of a zclass from a dtml 
method that is within that zclass?  in a python script, this is exposed 
as the "container" variable (assuming the binding is set, of course), 
but in a dtml method i can't figure out how to make it happen.

specifically, i have a dtml method called "detail_html" and a python 
script called "detail", both in a zclass that does NOT actually live in 
the zope object file system (it's a loginmanager user object).  i'd like 
to have the detail_html method work like this:

<dtml-with "detail()">
...
...
</dtml-with>

such that the detail python script returns a namespace which populates 
the dtml method.  nothing i do seems to work, though... "detail" doesn't 
exist in the global namespace, nor in "_".

my workaround is to have the python script call the dtml method and then 
return it, like so:

...
...
return container.detail_html(context, subdict)

where "subdict" is a dictionary of values that are then exposed in the 
dtml method's namespace.  this works, but it's less than ideal, because 
it needlessly obfuscates the code, IMO.  i don't want my front-end 
designers to have to be digging through complicated python code to 
figure out which dtml methods are being used... i'd much rather have 
them just see the dtml code, which would quietly suck in the data from 
the python script using <dtml-with>.

am i missing something obvious?

-r