On Sun, Jul 26, 2009 at 11:00 PM, Rob McC <hgle...@gmail.com> wrote:

>
> I am getting the hang of web2py, and having a lot of fun learning this
> superb framework.
>
> Question:
> In the "from PHP to web2py" documentation Should
>    return dict()
> read
>    return dict(form=form)


Maybe we could get Massimo to post the typical workflow for a request (the
new book draft image on Page 6 --- really makes things clear).

The way to think of this:   the return on index actually passes it's return
to the View (mapped by web2py to match the view for the request).

If you read this as

def index():
    send dict() -> view.default.index.html()

then you will see this is correct.  For   "send dict( form=form )"   you are
saying  the view's 'form' variable will recieve the controller's form
variable.   Since in this example, the body of the index view does not
output the value of any of it's variables (only constants - it is using a
variable for loop control, but is outputing a constant string 5 times), this
is unnecessary.

If somewhere you had in the view  ...  {{=form}}   (which you read as
"output the value of form)   then your index() controller would need to have
something valid to pass, e.g. something that would logically say something
along the lines of:

   send dict( view.form = controller.form )

I hope I'm not taking too many liberties with paraphrasing what this is all
really saying.

Does this make sense now?


>
>
> Or am I mission something?
>
> Many thanks,
> Rob
>
> REFERENCE:
> from PHP to web2py
> http://www.web2py.com/AlterEgo/default/show/106
>
> - - - - - - - - - - - - - - - - - - -
> AS STATED: (didn't work)
> - - - - - - - - - - - - - - - - - - -
> def index():
>    form=FORM(INPUT(_name="n"),INPUT(_type="submit"))
>    if form.accepts(request.vars):
>        session.n=form.vars.n
>        redirect('hello')
>    return dict()
>
> - - - - - - - - - - - - - - - - - - -
> THIS WORKS FOR ME:
> - - - - - - - - - - - - - - - - - - -
> def index():
>    form=FORM(INPUT(_name="n"),INPUT(_type="submit"))
>    if form.accepts(request.vars):
>        session.n=form.vars.n
>        redirect('hello')
>    return dict(form=form)
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to