Form-Through-Script Nightmare

tonylabarbara at aol.com tonylabarbara at aol.com
Tue Aug 14 15:47:02 EDT 2007


Hi;
I originally submitted this to the Zope list, but after no replies and realizing it's probably better suited for the python list, I'm submitting it here.


I have a form where purchasers can deselect items they've added to their shopping cart. All the hidden fields have been numbered according to the items they *originally* selected. If they deselect an item, then it will probably necessitate a renumbering of all those hidden fields, since PayPal doesn't tolerate misnumbering: everything must be numbered "1" for all the hidden fields of the first product, "2" for the second, etc. If the customer selects 5 products and deletes the 3rd, then I need to renumber. I wrote a script that can do that. Now, I have to send the form to that script, with all its lovely hidden fields, then reproduce it somewhere so I can send it off to PP. That is, the form must return from the called script to a new page and deliver all the renumbered hidden fields. 

?

Let me summarize what I've written before to put in one post exactly what's going on:


1)?I have a form that I need to send to a script and then send off to a URL (PayPal). I need to process it through the script to renumber things for PP. How do I do this? I imagine I add an element to the PT like so:

<form action="renumberTheCart(here/CheckOutAfterEditStuff)" method="post">

but I need to pass a parameter "doc", which, of course, is the document I'm submitting. So I tried this:

<form action="renumberTheCart(here/CheckOutAfterEditStuff)" method="post">
<p metal:use-macro="here/CheckOutAfterEditStuff/macros/main" />

which renders my page fine, but throws an error when I submit the form:

Cannot locate object at: http://example.com/s/c/x/j/en-us/s/renumberTheCart%28here

meaning, of course, that it didn't receive the required parameter.

2) I changed it to an absolute URL just to double-check, and got basically the same error:
?

Invalid request

The parameter, doc, was omitted from the request. 


How do I pass the parameter, which in my case is quite long and stashed neatly away in a PT macro?

<td tal:define="docs here/CheckOutAfterEditStuff">
<form action=http://example.com/s/renumberTheCart?doc=docs" method="post">?
<p metal:use-macro="here/CheckOutAfterEditStuff/macros/main" />?
</td>


Now, Tom Von Lahndorff suggested the following:


Sounds like the script should check to see if the user is removing something like:

<input type="checkbox" name="remove" value="item-374623746">




if remove

remove the item

redirect back to the udpated form page

else

send to PP




this way once the item is removed and the same script is called, since there's no remove this time, it'll go to PP.


I would LOVE to do that...if I knew how! Any ideas?
TIA,
Tony




?

Invalid request

The parameter, doc, was omitted from the request. 


How do I pass the parameter, which in my case is quite long and stashed neatly away in a PT macro?

<td tal:define="docs here/CheckOutAfterEditStuff">
<form action=http://example.com/s/renumberTheCart?doc=docs" method="post">?
<p metal:use-macro="here/CheckOutAfterEditStuff/macros/main" />?
</td>


Now, Tom Von Lahndorff suggested the following:


Sounds like the script should check to see if the user is removing something like:

<input type="checkbox" name="remove" value="item-374623746">




if remove

remove the item

redirect back to the udpated form page

else

send to PP




this way once the item is removed and the same script is called, since there's no remove this time, it'll go to PP.


I would LOVE to do that...if I knew how! Any ideas?
TIA,
Tony



________________________________________________________________________
AOL now offers free email to everyone.  Find out more about what's free from AOL at AOL.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070814/9750b740/attachment.html>


More information about the Python-list mailing list