[Zope] evaluating a string as an expression

Tony McDonald tony.mcdonald@ncl.ac.uk
Mon, 04 Mar 2002 22:27:40 +0000


On 4/3/02 9:17 pm, "Greg Conway" <greg@gmlnt.com> wrote:

> Hi Tony,
> 
> Yes, this is almost exactly what I am after, however I have one further
> question based on your answer!
> 

Greg,
I've cc'ed the list as it may help others.

>> 
>> It looks like you create variables from a form, specify1, specify2 ...
>> specifyn
> 
> Exactly! Created with a <dtml-in> loop based on an SQL method returning a
> variable number of rows, therefore I am unsure of the value of n.

Something like?

<dtml-in stuff>
<input type='text' name='<dtml-var specify_var>' value='<dtml-var
specify_value>'>
</dtml-in>

So you end up with

<input type='text' name='specify1' value='182'>
<input type='text' name='specify2' value='13'>
<input type='text' name='specify3' value='29'>
<input type='text' name='specify4' value='27'>

???

>> This is easier to do in python though (pass my_list as parameter) (again,
>> untested, and no checks to make sure those variables *do* exist)
>> 
>> request=context.REQUEST
>> for a_var in my_list:
>>     print request[a_var]
>> return printed
>> 
> 
> This is where the problem lies. I cannot create a list (afaik!) as these are
> variables placed in the REQUEST by a form submit button.

Oh yes you can! :)

<dtml-in stuff>
<input type='text' name='specify:list' value='<dtml-var specify_value>'>
</dtml-in>


And you use it like this in the target form.

<dtml-in specify>
 <dtml-var sequence-item>
</dtml-in>


Hth
Tone
-- 
Dr Tony McDonald,  Assistant Director, FMCC, http://www.fmcc.org.uk/
The Medical School, Newcastle University Tel: +44 191 243 6140
A Zope list for UK HE/FE  http://www.fmcc.org.uk/mailman/listinfo/zope