[Twisted-Python] Woven web question about clearing http request.args
I've got multiple input buttons and their view is the same logic. The logic is delete some data on a button press, then rerender the page with the updated data. The data it will remove depends on the unique ID of the button pressed. When the web page is rerendered the view gets called for each button with the same http request, so the deletion logic will be evaluated for each button, even though it should be evaluated for just the button that was pressed. I don't like that. I want to clear request.args so the behavior will be as if there was only one http event, corresponding to a single button press. I tried "request.args.clear()", but that doesn't seem to have the expected effect. What's worse is when I click the browser's reload button, request.args still has the last http request that occurred. In other words, if I click my delete button the page will be rerendered with updated data, then if I click the browser's reload it will try to delete more data as if I had hit on of my delete buttons again. Can anyone help me with this problem? _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Hegedus, Matthew S wrote:
I've got multiple input buttons and their view is the same logic. The logic is delete some data on a button press, then rerender the page with the updated data. The data it will remove depends on the unique ID of the button pressed. When the web page is rerendered the view gets called for each button with the same http request, so the deletion logic will be evaluated for each button, even though it should be evaluated for just the button that was pressed. I don't like that. I want to clear request.args so the behavior will be as if there was only one http event, corresponding to a single button press. I tried "request.args.clear()", but that doesn't seem to have the expected effect.
The view factory is called once per use of that view in the template. If you use the view for three buttons, your view factory gets called three times. Whether there were any button presses or not. Maybe you should move your "delete" logic from the view to the render method, or to a model that is used only once in the template. That is only called once per request, and is a logical place to do some processing.
What's worse is when I click the browser's reload button, request.args still has the last http request that occurred. In other words, if I click my delete button the page will be rerendered with updated data, then if I click the browser's reload it will try to delete more data as if I had hit on of my delete buttons again. Can anyone help me with this problem?
You should use a POST method for submitting the form; then the browser is not allowed to just resend the request without confirming the action from the user.
participants (2)
-
Hegedus, Matthew S
-
Tommi Virtanen