[Zope] Newbie DTML question

Plamen Nikolaev pan@aster.net
01 Feb 1999 09:36:09 +0200


Timothy Grant <tjg@avalongroup.net> writes:

> Hi again,
> 
> Is it possible to create a variable under DTML and assign it a value?
> 
> I can figure out how to assign the properties of a document or folder, but
> I cannot figure out how to assign a value to a one-off variable that I need
> temporarily.
> 
> I have messed around with _.namespace(), but nothing I do there seems to
> work correctly.

I think <!--#with _.namespace(tempvar=tempval) --> use tempvar here
... <!--#/with--> should do it, although I haven't tried it yet.

> 
> Also, it seems that it is possible to create an indirect variable when
> doing forms processing e.g.,
> 
>         <td>
>           <B><!--#var Category--></B>
>         </td>
>         <td>
>           <select name=<!--#var Category--> size=1>
>             <!--#in "PriceTable(PriceGroup=_['Category'])"-->
>               <option><!--#var Description-->
>             <!--#/in-->
>           </select>
>         </td>
> 
> As far as I can tell I'm creating a select box named with whatever happens
> to be stored in Category at the moment. However, I can't seem to access the
> contents of the indirect variable. 

_[Category] should give you indirect access to the variable whose name
is the value of Category.  Note the lack of quotes around Category (as
opposed to your code above).

Tell me if this doesn't work for you (and I'll look more into it).

Regards,
Plamen

[...]