Mangle function name with decorator?
R. David Murray
rdmurray at bitdance.com
Wed Mar 18 11:11:55 EDT 2009
> class foo_controller(Controller):
> __metaclass__= ControllerMetaclass
> def __init__(self, action, method = None):
> self.action = action
> self.method = method
>
>
> def foo(self):
> print "in foo()"
>
> @get_only
> def foo(self):
> print "in get_only foo()"
>
> def bar(self):
> print "in bar()"
I don't have any wisdom on the metaclass/decorator stuff, but what
about slightly reformulating the interface? Instead of having the
programmer type, eg:
@GET
def foo(self): pass
@POST
def foo(self): pass
have them type:
def GET_foo(self): pass
def POST_foo(self): pass
It's even one less character of typing (the <cr> :)
--
R. David Murray http://www.bitdance.com
More information about the Python-list
mailing list