[Zope] Passing Variables Through Multiple Forms

Milos Prudek milos.prudek@tiscali.cz
Tue, 30 Oct 2001 11:02:43 +0100


Ben Ocean wrote:
> 
> Hi;
> What is the best way to pass variables defined in one form to a second
> form? Is there a tutorial available (couldn't find a HOW-TO).

When the variable(s) should cross just one form, and there are just a
few variables, I do this:
<dtml-call "REQUEST.set('name',name)">
<dtml-call "REQUEST.set('address',address)">
The code above must be written in the second page, which received the
name and address from a form in the first page, and which must provide
this data to the third page.

When the variable(s) should cross many pages, when there are many
variables, or when you accumulate variables as you take the user through
multiple pages, I use CoreSessionTracking. Example:

First page collects name and address using a html form. Second page
contains this code:
<dtml-call "save_data(REQUEST.form)">

save_data is a Python Script, parameter is form_data:
data=context.SDM.getSessionData()
data.set('form',form_data)

That is all you need to save data. 

To retrieve data:
<dtml-let data="SDM.getSessionData(create=0)['form']">
   <dtml-var "data.get('name')"><br>
   <dtml-var "data.get('adress')"><br>
</dtml-let>

The examples above are probably a tad clumsy (non-elegant). But they
work just fine. Comments welcome!

--
Milos Prudek