durusmail: quixote-users: Passing values to a form
Passing values to a form
[PATCH] form.Form.form_submitted
2003-09-28
2003-09-29
Passing values to a form
Jason Sibre
2003-09-28
>
> One approach would be to change the Form.form_submitted(request)
> to be a bit
> smarter.  It could return true only if the form data includes info on all
> widgets (expect checkboxes, which may not be included if there is
> no value?)


This is essentially how I have handled this type of situation.  More
specifically, in my app, I have:
############################################
class Form(quixote.form.Form):
    ...
    ...
    def __init__(self, Wobj=None, app=None, enctype=None):
        quixote.form.Form.__init__(self, enctype=enctype)
        ...
        ...
        self.add_widget("hidden",
             "magic_form_submission_detection_hidden_input",
             value=1)
    ...
    ...

    def form_submitted (self, request):
        """form_submitted(request : HTTPRequest) -> boolean

        Return true if a form was submitted in the current request.
        """
        #return len(request.form) > 0
        return
request.form.get("magic_form_submission_detection_hidden_input") != None
############################################

However, I wrote this a while back, and I think some brief investigation
into the Quixote form tokens may provide a more elegant solution...  You'll
need sessions working in order to use the form tokens, though.

Jason





reply