Passing variables between scripts

Bjorn Pettersen bjorn at roguewave.com
Tue Jun 27 12:35:03 EDT 2000


Olav Viken wrote:
> 
> Can anyone tell me if there is a good way to pass a variable between two CGI
> scripts?

There are many variations of this, but you can do a lot with the
following model:

  form1 -> cgi1 -> form2 -> cgi2

meaning that your starting html page contains form1. When submitting the
form, you call cgi1 which during it's processing prints form2. When
form2 is submitted it calls cgi2.

If you only have simple values (and don't require a very secure system),
cg1 can print out a <input type="hidden" name="foo" value="%s"> tag
where you substitute the %s for the repr of a dictionary containing all
the values you want to pass.  You can then use eval on the value in cgi2
to resurrect the dictionary (as I said, not particularly safe, but easy
;-)

hth,
-- bjorn




More information about the Python-list mailing list