ok.

There was an error in your code, a double call to process() .....
But there was also on my end: when you do in the same function that shows 
the form a fast_tz_detector(), basically you trigger a POST request that 
"updates" the formkey associated with the form. 
Blame on me that use LOAD() all the times.

In order to avoid intricacies of CSRF (that you can definitely circumvent 
by hand, but it's not recommended if you don't understand all the 
implications), it's better either to check for the timezone earlier in the 
process.
Actually the module is in use in a site of mine, where a default "landing 
page" is hit by every user before having the possibility to fill a form ... 
also, it's not useful to check for the user timezone everytime he loads a 
page ^_^.
Even so, if you want to detect the timezone in the same page where there is 
the form, your "safest" resort would be to include a LOADed component that 
triggers the timezone detection.....

Summary: here's the code to accomplish timezone detection in the form....
def mytzdetector(): #just does timezone detection
    fast_tz = fast_tz_detector()
    return dict(fast_tz=fast_tz)

def test():
    if not session.plugin_timezone_tz: #if it's already set, skip detection
        fast_tz = LOAD('default', 'mytzdetector.load', ajax=True) #load 
with ajax
    else:
        fast_tz = None

    form = SQLFORM(db.sometable)
    
    if form.process().accepted:
        response.flash = 'form accepted'
    elif form.errors:
        response.flash = 'form has errors'
    else:
        response.flash = 'please fill out the form'
    return dict(form=form, fast_tz=fast_tz)


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to