I really don't get the use of {{form....}} in views. It's really too
opaque.  The form=crud and form=SQLFORM really only do trivial cases
involving a single table.

What I want to do is just create an html input form in the view with a
submit action.

When the http request comes back with variables for each input field
in the form I want to grab the returned values and put them in the
databases (plural) myself.  This is the only way to get the required
control and make the code and view obvious.

Do I use request.vars to get the returned values?  There is something
like form.vars and form.accepts in the manual.  But, there is simply
not enough information.   I have to process form.accepts before return
dict(form=form).

The flow is really confusing. When is the form/view sent to the
client?  After submit is clicked by the user, when does the controller
receive the request (with Get/Put values)?  The problem as I see it is
that a function in a controller only "sends" its bits to the view when
the function hits "return dict(form=form)" .  But, then the function
is over--where do I put the logic for processing the user's reply
(e.g.--request.vars)?  It appears BEFORE the return--but the view
hasn't gone to the client yet.  Or is it effectively a loop--as long
as the request (the user's reply) comes back to the same url the
controller runs again, but this time with the submitted form.  I am
thinking this must be what happens.  It is very hard to experiment to
figure this out because of all my runtime errors and the very
challenging diagnostics (layers upon layers of calls through the
framework itself).

This whole flow thing would be more obvious if I could use yield
instead of return.  It seems like what is really needed is something
like this:

def controller_func():
     prepare info to send to the user in the view

     send the view--e.g., yield dict(form=form)

     receive "request" from the user after submit (or other action)

     do things with what has been received from the user
           if form.accepts(?, ?):
                x = request.vars.x
                db.foo.insert(name=x) etc.

     redirect or next URL

     return (end of function--nothing sent to view)

The flow above is far more obvious and follows the stateless
transactional model of http.

Sorry if I am hopelessly stupid, but the manual offers a woeful lack
of complete examples. There isn't even complete documentation of each
class and all of its methods.  I did look at the doc strings on the
FORM function (is it a function? a class?  ???).  Accepts seems to be
the method I want, but it is not clear when it runs.  It is not clear
when the validators run.  It is not clear if I access returned values
(request) with request.vars or form.vars.


Again, sorry but there is just not enough for me to comprehend it.
Decent examples go a long way.    Either no one has time or everyone's
expertise is so far beyond mine. I have looked through all items
tagged form on web2py slices but these are also very fragmentary.  I
apologize profusely for my stupidity.  I just need more complete code
examples to run and study.

Reply via email to