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.