You no longer have to @expose() generic controller handlers. You can
simply pass through any keyword arguments you like, just as you would to @expose(). See tests for examples.
This commit is contained in:
@@ -6,8 +6,9 @@ def _cfg(f):
|
|||||||
|
|
||||||
|
|
||||||
def when_for(controller):
|
def when_for(controller):
|
||||||
def when(method):
|
def when(method=None, **kw):
|
||||||
def decorate(f):
|
def decorate(f):
|
||||||
|
expose(**kw)(f)
|
||||||
_cfg(f)['generic_handler'] = True
|
_cfg(f)['generic_handler'] = True
|
||||||
controller.pecan['generic_handlers'][method.upper()] = f
|
controller.pecan['generic_handlers'][method.upper()] = f
|
||||||
return f
|
return f
|
||||||
|
|||||||
@@ -11,13 +11,11 @@ class TestGeneric(object):
|
|||||||
def index(self):
|
def index(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@index.when(method='POST')
|
@index.when(method='POST', template='json')
|
||||||
@expose('json')
|
|
||||||
def do_post(self):
|
def do_post(self):
|
||||||
return dict(result='POST')
|
return dict(result='POST')
|
||||||
|
|
||||||
@index.when(method='GET')
|
@index.when(method='GET')
|
||||||
@expose()
|
|
||||||
def do_get(self):
|
def do_get(self):
|
||||||
return 'GET'
|
return 'GET'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user