[Zope] how to avoid REQUEST.set

Thomas B. Passin tpassin@mitretek.org
Thu, 1 Nov 2001 10:54:46 -0500


I wrote -


> [seb bacon]
>
> > * 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?
> >
>
> 1) You can create a page or folder property,  and set and access that.
>

I was a bit too hasty here.  If a second page request came in at the wrong
time, the property could get changed before the first value were used.
Session variables would be better.

> 2) You can redesign things so that your templates get called and return
> values.  One of the returned values could be that color.
>

Cheers,

Tom P