Thank you very much Anthony.

I have read Chapter 7 up to the "Hidden Fields" section and it is
already more clear in my head.

Archibald


On 28 oct, 02:12, Anthony <abasta...@gmail.com> wrote:
> On Thursday, October 27, 2011 7:57:31 PM UTC-4, Archibald Linx wrote:
>
> > 1) Sometimes I see in the documentation "if form.process().accepted:"
> > and sometimes "if form.accepts(request.vars, session):". What's the
> > difference between the two ?
>
> form.process() was added very recently and is now preferred over
> form.accepts (though the latter is still perfectly fine).
> Seehttp://web2py.com/book/default/chapter/07#The-process-and-validate-me....
> form.process() does the same thing (it actually calls form.accepts()), but
> returns the form itself (hence the need to add .accepted if you want to see
> if it was accepted).
>
>
>
> > 2) On page 109 (
> >http://www.web2py.com/book/default/chapter/03#An-Image-Blog
> > ), I have not really understood the following sentence :
>
> > "Line 9 processes the submitted form (the submitted form variables are
> > in request.vars) within the current session (the session is used to
> > prevent double submissions, and to enforce navigation)."
>
> > Line 9 refers to : "form.accepts(request.vars, session):"
>
> > Would it be different if I would just write :
> > "form.accepts(request.vars):" ?
>
> Yes, if you leave out the session, it won't create a hidden _formkey field
> and store the value in the session. This is the mechanism web2py uses to
> prevent double form submission and CSRF attacks.
> Seehttp://web2py.com/book/default/chapter/07#Hidden-fields.
>
>
>
>
>
>
>
>
>
> > 3) On page 108 (
> >http://www.web2py.com/book/default/chapter/03#An-Image-Blog
> > ), there is written  :
>
> > if form.process().accepted:
> >     response.flash = 'your comment is posted'
>
> > On page 112 (http://www.web2py.com/book/default/chapter/03#Adding-CRUD
> > ), there is written :
>
> > form = SQLFORM(table)
> > if form.process().accepted:
> >     session.flash = '...'
>
> > Why is it sometimes "response.flash" and sometimes "session.flash" ?
>
> response.flash if the form page will be reloading; session.flash if you are
> redirecting to a new page.
> Seehttp://web2py.com/book/default/chapter/07#Forms-and-redirection.
>
> Basically, things should hopefully clear up when you read the forms chapter.
>
> Anthony

Reply via email to