Re: [web2py] Requiring arguments

2010-02-12 Thread Tiago Almeida
Shouldn't be hard to implement that decorator, though. I'll try later (at work now) because this is useful. Regards, Tiago On Fri, Feb 12, 2010 at 12:19 AM, minh mdn0...@gmail.com wrote: Is there a way to require arguments/vars in the controller functions other than explicitly checking for

Re: [web2py] Requiring arguments

2010-02-12 Thread Tiago Almeida
Hello, I think i've finished doing this but I'm having trouble accessing the request object from the decorator function. How would you define a decorator that accesses the request? I have something like this class require_args(object): def __call__(self, f): def

Re: [web2py] Requiring arguments

2010-02-12 Thread Tiago Almeida
Sorry, spoke too soon. I saw how auth works and did something similar. right now it is something like this, mind that names can be changed: @req_args.requires_validVars( 'www.google.com', ('search',), ('search','highlight')) first param is where to redirect on error

Re: [web2py] Requiring arguments

2010-02-12 Thread Thadeus Burgess
what about default cases. I don't need to redirect if a var does not exist, but instead use a default value. Perhaps a dict instead of tuples ? -Thadeus On Fri, Feb 12, 2010 at 7:53 PM, Tiago Almeida tiago.b.alme...@gmail.com wrote: Sorry, spoke too soon. I saw how auth works and did

Re: [web2py] Requiring arguments

2010-02-12 Thread Tiago Almeida
Yes it's a possibility! -- Tiago On Sat, Feb 13, 2010 at 2:06 AM, Thadeus Burgess thade...@thadeusb.com wrote: what about default cases. I don't need to redirect if a var does not exist, but instead use a default value. Perhaps a dict instead of tuples ? -Thadeus On Fri, Feb 12, 2010

[web2py] Requiring arguments

2010-02-11 Thread minh
Is there a way to require arguments/vars in the controller functions other than explicitly checking for them? It would be nice if we could decorate the functions similar to how the auth works, ex: @require_arg_function(minargs=2, message=Invalid arguments) def some_function(): Thanks.

Re: [web2py] Requiring arguments

2010-02-11 Thread Thadeus Burgess
if not request.args(0): redirect() or default = hi -Thadeus On Thu, Feb 11, 2010 at 6:19 PM, minh mdn0...@gmail.com wrote: Is there a way to require arguments/vars in the controller functions other than explicitly checking for them? It would be nice if we could decorate the