[Zope] REQUEST actions
AP Meyer
a.p.meyer at fel.tno.nl
Mon Mar 22 05:55:49 EST 2004
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
------------------------------------------------------------------------------
More information about the Zope
mailing list