On Sunday, February 20, 2011 11:01:38 PM UTC-5, rochacbruno wrote:
>
> Nice! I did not know about it, I always avoid the use of callable because
> I knew it was deprecated in python 3.
>
You're excused for not knowing about it, as it was literally released just a
few hours ago. :)
> But n
On Sunday, February 20, 2011 10:34:19 PM UTC-5, rochacbruno wrote:
>
>
>> Could you also use
>>>
>>> elif callable(locals().get(request.args(0)))
>>>
>>
>> Don't use callable(), as this is being deprecated
>>
>
> Actually, apparently it has just been resurrected in Python 3.2:
> http://docs.python
On Sunday, February 20, 2011 10:34:19 PM UTC-5, rochacbruno wrote:
>
>
> Could you also use
>>
>> elif callable(locals().get(request.args(0)))
>>
>
> Don't use callable(), as this is being deprecated
>
Actually, apparently it has just been resurrected in Python 3.2:
http://docs.python.org/re
> Could you also use
>
> elif callable(locals().get(request.args(0)))
>
Don't use callable(), as this is being deprecated
>
> Or maybe:
>
> try:
> return locals().get(request.args(0), locals)()
> except TypeError:
> return locals().get(request.args(0), locals)
>
Thanks, I am going to us
Could you also use
elif callable(locals().get(request.args(0)))
Or maybe:
try:
return locals().get(request.args(0), locals)()
except TypeError:
return locals().get(request.args(0), locals)
Anthony
On Sunday, February 20, 2011 10:02:24 PM UTC-5, rochacbruno wrote:
> I drop the need
I drop the need of inspect by using hasattr(obj ,'__call__'):
### TODO: encapsulate the code below ###
if not request.args(0) in locals():
return locals()
elif* hasattr(locals().get(request.args(0)),'__call__')*:
return locals().get(request.args(0),locals)()
else:
I am going with this solution for a multicomponent app(working together with
web2py components), I just do not know if I can rely on this inner
functions, the return of locals() and the use of inspect. without the chance
to break the compatibility in the future.
###
I figure out that this is a nice way to access objects directly by the
request URL, no need to use the .load extension, and I got the same output
as I expect in shell.
example:
#
def wrapper():
div = DIV('wrapper',BR(),H
>
>
> I think you need something more like:
>
> if request.args(0) in locals():
> return locals()[request.args(0)]()
> return locals()
>
> But I think for security reasons you might also test for request.args(0) in
> ['fun1', 'fun2']. Otherwise you could get some strange results.
>
On Feb 20, 2011, at 5:52 PM, Bruno Rocha wrote:
> I just made a test
>
> ## controller ###
>
> def wrapper():
> div = DIV('main wrapper',BR(),HR())
> def fun1():
> div = DIV('function2',BR(),HR())
> return locals()
>
> def fun2():
>
I just made a test
## controller ###
def wrapper():
div = DIV('main wrapper',BR(),HR())
def fun1():
div = DIV('function2',BR(),HR())
return locals()
def fun2():
div = DIV(' function 2',BR(),HR())
return locals()
return
On Feb 18, 4:03 pm, VP wrote:
> This is an interesting idea. I am wondering if by doing this, we
> can:
>
> + treat controllers as regular Python functions, which have
> parameters.
> + implement some type of automatic type checking on request.args (e.g.
> for int or string)
these two would b
I use this for helper functions.
On Fri, Feb 18, 2011 at 11:03 PM, VP wrote:
> This is an interesting idea. I am wondering if by doing this, we
> can:
>
> + treat controllers as regular Python functions, which have
> parameters.
> + implement some type of automatic type checking on request.arg
This is an interesting idea. I am wondering if by doing this, we
can:
+ treat controllers as regular Python functions, which have
parameters.
+ implement some type of automatic type checking on request.args (e.g.
for int or string)
+ simplify redirect. For example, instead of redirect(URL('edi
Not sure it can be done (at least not in a clean nice way portable
across python implementation).
On Feb 18, 2:53 pm, Bruno Rocha wrote:
> This is really cool!
>
> I think it deserves a decorator.
>
> @action_wrapper()
> def my_action_wrapper():
> def one_action():
> return dict()
>
This is really cool!
I think it deserves a decorator.
@action_wrapper()
def my_action_wrapper():
def one_action():
return dict()
def another_action():
return dict()
So the decorator adds the "return locals().get..." part
2011/2/18 Massimo Di Pierro
> cool. I never
Thanks for this. I'm new so I'm glad that I am on the right track.
On Feb 18, 3:03 pm, Massimo Di Pierro
wrote:
> cool. I never thought about this. You can make it much simpler:
>
> def users():
> def index():
> return dict(message="List users")
> def new():
> return dict(
cool. I never thought about this. You can make it much simpler:
def users():
def index():
return dict(message="List users")
def new():
return dict(message="Add new user")
def edit():
return dict(message="Edit an existing user")
return locals().get(request.a
That is pretty much what Crud does, except in a class.
Have a look in gluon/tools.py
On Feb 18, 1:47 pm, Ross Peoples wrote:
> I am trying to make an 'admin' controller that will allow
> administrators of the app to administer different parts of the app.
> One of the things to administer will b
19 matches
Mail list logo