[Zope] Questions re: REQUEST, external methods; newbie stupidity at play

Jamie Heilman jamie@audible.transient.net
Wed, 16 Jul 2003 15:07:15 -0700


Bryan White wrote:
> Can you / how does one destroy variables / objects in DTML?

It isn't generally done, but that doesn't mean it can't be.  Take for
example the manage_tabs.dtml from the ZMI.  I rewrote mine a while
back to fix a host of annoyances including the leak of some its
"temporary" variables it uses into all other tabbed ZMI pages.  That
particular DTMLFile uses the variable a_ via a REQUEST.set('a_', ...)
to hold the sequence index of the currently active tab, at the end of
that file, rather than let the value of a_ leak into all the following
dtml manage_tabs is called from, I do:

<dtml-comment>don't leak a_</dtml-comment>
<dtml-if manage_options><dtml-call "REQUEST.other.__delitem__('a_')"></dtml-if>

It helps to understand how HTTPRequest objects really work, and
exactly what calling .set() does, and how and when keys of the request
object are promoted between the various dictionaries that make up
their internal storage.

The real zen is avoiding the need for ever using .set() at all.

-- 
Jamie Heilman                   http://audible.transient.net/~jamie/
"I was in love once -- a Sinclair ZX-81.  People said, "No, Holly, she's 
 not for you." She was cheap, she was stupid and she wouldn't load 
 -- well, not for me, anyway."				-Holly