OK, figured out the form:

form.accepts( request.vars, session ) includes protection against re-
submission.  You can't submit the same form twice.

Is there an API document somewhere that would tell me that?
I know of the following API docs:

  best: http://www.web2py.com/examples/static/epydoc/index.html (also
included in your downloaded web2py).  The primary value here is that
the APIs all include the link to the source code (Use the Source,
Luke!)

These other two aren't helpful to me, because they don't list function
arguments or describe the functions or data members:

  * http://web2py.com/book/default/docstring/FORM
  * http://www.web2py.com/examples/default/api


Any where else I should be looking?

Thanks

kb
On Apr 1, 5:09 pm, Kevin Butler <[email protected]> wrote:
> I spent way too much time figuring out what was happening with these
> two issues, because their interaction sent me debugging various wrong
> paths.
>
> But in essence, I found two behaviors that were unexpected and which
> not provide an easy way to identify the problem.
>
> #1)  If you call form.accepts a second time, it always returns false.
>
> That is, in the following code, you can get a "You have to enter a
> value" or "True then false", but you can never get "You can't get
> here":
>
> def index():
>     form = FORM(
>         INPUT( _name="value", requires=IS_NOT_EMPTY()),
>         INPUT( _type="submit" )
>         )
>     if form.accepts( request.vars, session ):
>         if form.accepts( request.vars, session ):
>             response.flash = "You can't get here"
>         else:
>             response.flash = "True then false"
>     else:
>         response.flash = "You have to enter a value"
>
>     return dict( form=form )
>
> Is this by design?  Why?  If it /is/ by design, can we please have the
> second "form.accepts" throw a nasty exception so we can avoid it?
>
> #2) If you store an instance of a custom class variable in a session
> variable, you will invisibly get a new, clean session on the next
> request.  That is, in the following code, you can get "We'll get it
> next time", but you just can't get "You can't get here" (unless you
> cheat)
>
> class X:
>     pass
>
> def index():
>     if session.nextTime:
>         response.flash = "You can't get here"
>
>     session.x = X()
>     session.nextTime = 1
>     response.flash = "We'll get it next time"
>
>     return dict( session=session )
>
> I imagine this is happening because of something like unpickling in
> the framework (maybe?), but instead of silently getting a new session,
> I'd much again much rather have an exception thrown...
>
> kb

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

Reply via email to