[Zope] how to avoid REQUEST.set

seb bacon seb@jamkit.com
Thu, 1 Nov 2001 14:02:42 +0000


* Jens Vagelpohl <jens@zope.com> [011101 12:44]:
> as far as the "REQUEST.set-sledgehammer" goes, most of its uses can be 
> replaced by dtml-let, which has the added advantage that you can look at 
> the code and see where a variable came from much faster than scanning all 
> code for REQUEST.set. maybe it's just me, but i consider REQUEST.set bad 
> style that should be used only if nothing else works.

I dislike the 'set' hammer too, but there's one scenario in which it
seems to be unavoidable: if you need to set a variable which must be
accessed from several templates.  For example, I may have a
navigation bar in one template, the colour of which I want to change
depending on tests which take place in a content template.  Since
<dtml-let> can't span more than one template, is there any other way
of manipulating a global namespace in the context of a single
request?

seb

> On Thursday, November 1, 2001, at 02:13 , Anthony Baxter wrote:
> 
> >Like any site that's been around for a while, we've got a lot of
> >DTML that shouldn't be DTML. We're gradually killing it, but
> >we're looking at detecting stuff that _shouldn't_ be in DTML.
> >One metric that's come up is "any DTML method that has 3 or more
> >calls to REQUEST.set() is probably up to no good."
> >
> >Have other people found other useful rules of thumb about when
> >to avoid DTML?