Dear Zopers Here is another question that I cannot find a satisfying solution for. The situation is that I have a ZPT with a list (batched table) from which I can select items to edit and add there is a button to add new items. This button is part of a form like this: <form action="." method="post"> <p> <input type="submit" name="delItems:method" value="Delete Poets"/> <input type="submit" name="manage_addItemForm:method" value="Add Item"/> </p> ... </form> Pressing the "Add Item" button invokes the manage_addItemForm and modifies the URL in the REQUEST object accordingly. On that form one can enter all item details and press an "Add Item" button that is programmed like this: <form method="post" action="addItem"> <table> <tr> <th class="left">Name</th> <td><input type="text" name="title" size="72"/></td> </tr> <tr> <td colspan=2 align="center"><input type="submit" value="Add Item"/></td> </tr> </table> </form> This still works fine and calls the appropriate method in the Product's class. That method looks like this: def addItem(self, title, REQUEST=None): "Method to add an item." id = self.newId() item = Item(id, title) self.Library._setObject(id, item) if REQUEST is not None: return self.listItems(REQUEST) def listItems(self, REQUEST=None): "Method to list items." _request = {'meta_type':category} _results = self.Catalog.search(_request) if REQUEST is not None: REQUEST['results'] = _results return self.index_items(self, REQUEST) # <<< this does not modify REQUEST! else: return _results This still works well so far. The problem occurs here, however, that the URL of the REQUEST object is not modified as it is when using a form. It still contains the "addItem" action and its parameters (in QUERY_STRING) instead of "listItems". As a result, when the table is sorted, for example, the same item is added again !!! How can this behaviour be prevented or fixed such that the REQUEST contains the right information? your help is appreciated, many thanks Andre -- ------------------------------------------------------------------------------ The disclaimer that applies to e-mail from TNO Physics and Electronics Laboratory can be found on: http://www.tno.nl/disclaimer/email.html ------------------------------------------------------------------------------
AP Meyer wrote:
<form action="." method="post">
<form method="post" action="addItem">
How can this behaviour be prevented or fixed such that the REQUEST contains the right information?
Have absolute urls in the action of your forms, nto relative ones asa you have... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris Withers wrote:
AP Meyer wrote:
<form action="." method="post">
<form method="post" action="addItem">
How can this behaviour be prevented or fixed such that the REQUEST contains the right information?
Have absolute urls in the action of your forms, nto relative ones asa you have...
Chris
Having absolute URLS would mean that the name of the product's instance is included in the path, thus it can only be used with a fixed instance id. Or is there a way to retrieve the absolute URL from the action name? How would you specify an absolute URL in the form? thanks Andre
Andre Meyer wrote:
Having absolute URLS would mean that the name of the product's instance is included in the path, thus it can only be used with a fixed instance id.
Urm? Not sure what you mean here...
Or is there a way to retrieve the absolute URL from the action name? How would you specify an absolute URL in the form?
tal:attributes="href string:${here/absolute_url}/whatever" Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Chris Withers wrote:
AP Meyer wrote:
<form action="." method="post">
<form method="post" action="addItem">
How can this behaviour be prevented or fixed such that the REQUEST contains the right information?
Have absolute urls in the action of your forms, nto relative ones asa you have...
Chris
Does it matter, by the way, whether one uses GET and/or PUT as methods for the actions? What is preferrable? thanks Andre
Andre Meyer wrote:
Does it matter, by the way, whether one uses GET and/or PUT as methods for the actions?
No. Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
AP Meyer wrote at 2004-3-22 11:55 +0100:
... URL control ... This still works well so far.
The problem occurs here, however, that the URL of the REQUEST object is not modified as it is when using a form. It still contains the "addItem" action and its parameters (in QUERY_STRING) instead of "listItems".
When you want to get a different URL, the easiest way is to make a new request (by redirecting rather than calling). An alternative is to use the HTML "base" tag (see the HTML specification). With a "base" tag, the URL in the browser location widget will stay as it is, but relative URLs inside the page are resolved with respect to the base tag. -- Dieter
participants (4)
-
Andre Meyer -
AP Meyer -
Chris Withers -
Dieter Maurer