[Zope] best way to define variables for form parameterization?

Mitchell L Model mlm@acm.org
Fri, 17 Aug 2001 13:36:55 -0400


What's the best way to define variables to be used in a parameterized 
DTML document?

Let's say I have a folder hierarchy where all the folders can share a 
single index_html at the root, except that there are a couple of 
differences in various places that are not directly derivable from 
the usual variables (id, title, etc.).  For instance, an organization 
chart represented as a folder hierarchy, and a standard welcome page 
that includes among other things the physical location of the part of 
the organization represented by the selected folder and the phone 
number of the receptionist at that location.  My index_html page 
could have
	<dtml-var orgloc>
and
	<dtml-var receptPhone>
buried in it somewhere, then all I have to do is define orgloc and 
receptPhone at appropriate places in the folder hierarchy.  I could 
of course make them DTML Methods that just returned a string, but it 
seems pretty heavy-handed to define a method just to get a variable 
value.  Is there a better way to specify variable values?  Some kind 
of dictionary mechanism?  Suppose I had 10 or 20 such variables -- I 
wouldn't want to deal with the proliferation of one-line DTML Methods 
throughout the hierarchy.  I just want a way for each folder to 
register values of whatever variables it wants to override, for use 
by parameterized pages.

One thought I had was to subclass ObjectManager (either in Python or 
as a ZClass) and add a mechanism that looks in a dictionary stored in 
a "variables" instance variable, then if the desired variable wasn't 
there, look at the parent, etc.

Before I launch off into this escapade, please tell me if (a) there's 
a straightforward way to define variables like this; (b) the whole 
idea is confused; or (c) there's an available Product for this.