Hi everybody.

Im trying to validate a simple GET request using SQLFORM.factory. but cant 
get it to pass. I would like just to validate those variables but i dont 
know what im missing. On the docs theres not much info about forms and the 
get method but form.accepts(request.vars, ...). 

The url would be:
http://myapp/get_rates?rooms=5&agency=1


The controller:
def get_rates():
    # http://myapp/get_rates?rooms=5&agency=1
    
    print "request:",  request.vars
    # <Storage {'agency': '1', 'rooms': '5'}>
    
    form = SQLFORM.factory(
        Field("rooms", "integer", required=True)
        , Field("agency", "integer", required=True)
        , _method="GET"
    )
    #remove the auto id field
    form.fields.pop(0)
    
    
    print "accepts:", form.accepts(request.vars, session=None, dbio=False)
    # False
    print "validate:", form.validate(request_vars=request.vars, session=None
)
    # False
    print "fvars:", form.vars
    # {}

    if form.accepted:
        print "All good"
    elif form.errors:
        print form.errors
    
    print "Done"
    return 0.0

And the console output:
request: <Storage {'agency': '1', 'rooms': '5'}>
accepts: False
validate: False
fvars: <Storage {}>
Done

Version 2.12.3-stable+timestamp.2015.08.19.00.18.03

What would be wrong with the code above?
is there an easier way to validate a GET request?

Many thanks in advance.


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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/d/optout.

Reply via email to