[Zope] RE:How do I merge form & URL vars into sql easily
Michael Blewett
michael.blewett@sci.monash.edu.au
Fri, 07 Jul 2000 09:43:53 +1000
Hi Jake,
I originally had trouble coming to grips with the concept of variables and
forms and passing them from one object to the next. After much testing,
trial and error (and guidance from this list), I came up with these
conclusions (which I'm sure someone will shoot down if I am wrong):
1) The request object you are setting with your REQUEST.set command is like
a big bucket that gets passed between one web page and the next when you
call it in your DTML. The best thing someone ever showed me was how to view
in the called document ie.
insert the line:
<dtml-var REQUEST>
into the dtml/method you are trying to call.
If you do that you can see all of the variables that get passed normally as
part of your REQUEST variable, as well as any that get added to it by your
form in the act of your POST command in the form. Be prepared - it is a
long list! You should be able to see all your form variables in there. If
you don't then you haven't been doing your form correctly (been there done
that too!).
The only real 'nasty' I have come across so far id the checkbox - if it is
unchecked it doesn't post anything to the REQUEST object, and then you need
to check for it and set it, if you are using it to update an SQL database
(this is the only time I use the <dtml-call
"REQUEST.set['argument','value']">command. This is normal behaviour with
forms and is not the fault of Zope.
Hope this helps...
- Michael
> -----Original Message-----
> From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of
> asjf11@uaa.alaska.edu
> Sent: Wednesday, July 05, 2000 5:32 PM
> To: zope@zope.org
> Subject: [Zope] How do I merge form & URL vars into sql easily
>
>
> I am a new user to Zope and I'm trying to pass data that has been
> entered into a form (either through GET or POST) into another
> object. This object calls a z sql method to insert the form data into
> the database. So far, the only way I've found to pass data to the
> sql is to define arguments for it and then, in the dtml-document (or
> method) use:
> <dtml-call "REQUEST.set['argument','value']">
> (and it took me long enough to figure THAT out, let me tell you)
> The problem is that sucks when there are 30 form varibles that
> need to be inserted into the database.
> I would think that there is some way to let the sql method see
> these varibles that are defined within my document. Or loop
> through all URL or form varibles defined and sets all the vars in
> request. Something to keep from having to write the above dtml 30
> times. Thanks.
>
> Jake Feasel
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael Blewett
Computer Support Mgr - Biological Sciences
Monash University (Clayton Campus)
Victoria Australia 3168
" Can I trade this job for what's behind door #2? "