[Zope-DB] Help needed with multi-table insert form

Martin Gebert Murphy@members.netsolution-net.de
Thu, 23 Jan 2003 12:36:19 +0100


Charlie Clark schrieb:

>On 2003-01-23 at 01:13:58 [+0100], Martin Gebert wrote:
>  
>
>>@Norman: Alternatively (and more obvious), you could also use a script 
>>like
>>
>>request = context.REQUEST
>>
>>context.sql_INSERT_form(
>>    business_name = request.business_name,
>>    ...
>>    )
>>    
>>
>
>sure but this method doesn't allow the form to be checked. If you're going 
>to do this you might as well pass the REQUEST.form which is a dictionary 
>directly.
>
>context.sql_INSERT_form(request.form)
>
I can't agree completely - you can check the form values one by one 
before inserting, and even save them to local variables and do other 
manipulations. It's not as elegant, but maybe more clear to read (at 
least for an old procedural programmer ;-).
Say, if you want to check the values in your dictionary individually (e. 
g. the first has to be an integer, the second a string with a minimal 
length, the third is computed...) you need a "case" construct (which 
results in an "if/else if" cascade in Python), don't you? Or didn't I 
get anything?

Martin