[Zope] Updating a form's variables through a Python script

Don Mullins donm at creditprotect.com
Fri Sep 12 14:36:48 EDT 2003


Hi,

I have a form:

<dtml-var standard_html_header>

    <H1 align="center">
    <img src="/images/blockbuster.gif" width=200 height=124>
    <br>New Customer Add</H1>

    <a href="/BBI/New Customer Add"><font size="1">Reset</font></a>
    <HR width="75%">
    <P>

 <form action="." method="POST">
  <table align="center" width="100%">
  <tr><td>Customer ID:</td><td><input type="text" name="acct" size=20
maxlength=20 value="">&nbsp&nbsp<input type=submit name="Findem:method"
value="Find"></td></tr>
  <tr><td>Home Phone:</td><td><input type="text" name="phone" size="12"
maxlength="10" value="">&nbsp&nbsp<input type=submit
name="getaddress:method" value="Get Address"></td></tr>
  <tr><td>Customer Name:</td><td><input type="text" name="name" size="50"
maxlength="50" value=""></td></tr>
  <tr><td>Bill-To Name:</td><td><input type="text" name="bname" size="50"
maxlength="50" value=""></td></tr>
  <tr><td>Address 1:</td><td><input type="text" name="addr1" size="50"
maxlength="50" value=""></td></tr>
  <tr><td>Address 2:</td><td><input type="text" name="addr2" size="50"
maxlength="50" value=""></td></tr>
  <tr><td>City/St/Zip:</td><td><input type="text" name="city" size="50"
maxlength="50" value=""></td></tr>
  <tr><td>Work Phone:</td><td><input type="text" name="wphone" size="12"
maxlength="10" value=""></td></tr>
  <tr><td>Driver's License:</td><td><input type="text" name="dl" size="10"
maxlength="10" value=""></td></tr>
  <tr><td>e-mail address:</td><td><input type="text" name="email" size="40"
maxlength="40" value=""></td></tr>
  <tr><td>Notes:</td><td><textarea rows="3" cols="60"
name="notes"></textarea></td></tr>
  </table>
 </form>

<dtml-var standard_html_footer>

And a python script that gets called when a submit button is pushed:

from Products.PythonScripts.standard import html_quote
request = container.REQUEST
RESPONSE =  request.RESPONSE
session = request.SESSION

acct = request.get('acct', '')
phone = request.get('phone', '')
name = request.get('name', '')
bname = request.get('bname', '')
addr1 = request.get('addr1', '')
addr2 = request.get('addr2', '')
city = request.get('city', '')
wphone = request.get('wphone', '')
dl = request.get('dl', '')
email = request.get('email', '')
notes = request.get('notes', '')

s = container.getaddr(acct, phone, name, bname, addr1, addr2, city, wphone,
dl, email, notes)

session.set('acct', s[0])
session.set('phone', s[1])
session.set('name', s[2])
session.set('bname', s[3])
session.set('addr1', s[4])
session.set('addr2', s[5])
session.set('city', s[6])

session.set('back_url',request.HTTP_REFERER)
if session.has_key('back_url'):
  back_url = session.get('back_url')
#container.New_Customer_Add
#return s[4]
#return back_url
#return request 
#return RESPONSE.redirect(session.back_url) 
#return context.New_Customer_Add()
#return RESPONSE.redirect('New_Customer_Add?name='+s[2])
return context.New_Customer_Add(context, context.REQUEST, phone=s[4])   
#return context.REQUEST.RESPONSE.redirect(context.absolute_url())

Everything works great until I want to send the data back to the form.  As
you can see I have tried all kinds of possibilites with no success.

Any help on how to get the form variables returned would be greatly
appreciated.

Thanks.

Don Mullins
***************************************NOTE*******************************************
The information contained in this email message is intended only for use of the 
individual or entity named above, and may be legally privileged.  If the reader 
of this message is not the intended recipient, or the employee or agent 
responsible to deliver it to the intended recipient, you are hereby notified that
any dissemination, distribution or copying of this communication is strictly 
prohibited.  If you have received this communication in error, please immediately 
notify the sender, and delete and destroy the original message.  Although 
this email and any attachments are believed to be free of any virus or other
defect that might affect any computer system into which it is received and 
opened, it is the responsibility of the recipient to ensure that it is virus free and
no responsibility is accepted by the sender for any loss or damage arising in 
any way from its use.



More information about the Zope mailing list