core: do not assume controller is a method
If a controller is not a method (e.g. a staticmethod or a function), there's no need to pop up the self argument. That actually make the signature to mismatch, so let's fix that. Change-Id: Ia96b7d19b2b664381e422b7182d0437b841914dd
This commit is contained in:
parent
f4d923dca6
commit
a98e5f4547
|
@ -343,7 +343,9 @@ class PecanBase(object):
|
|||
args = []
|
||||
varargs = []
|
||||
kwargs = dict()
|
||||
valid_args = argspec.args[1:] # pop off `self`
|
||||
valid_args = argspec.args[:]
|
||||
if ismethod(state.controller) or im_self:
|
||||
valid_args.pop(0) # pop off `self`
|
||||
pecan_state = state.request.pecan
|
||||
|
||||
def _decode(x):
|
||||
|
|
|
@ -395,6 +395,11 @@ class TestControllerArguments(PecanTestCase):
|
|||
', '.join(list(args) + data)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@expose()
|
||||
def static(id):
|
||||
return "id is %s" % id
|
||||
|
||||
@expose()
|
||||
def _route(self, args, request):
|
||||
if hasattr(self, args[0]):
|
||||
|
@ -918,6 +923,11 @@ class TestControllerArguments(PecanTestCase):
|
|||
assert r.status_int == 200
|
||||
assert r.body == b_('variable_kwargs: list=%s' % l)
|
||||
|
||||
def test_staticmethod(self):
|
||||
r = self.app_.get('/static/foobar')
|
||||
assert r.status_int == 200
|
||||
assert r.body == b_('id is foobar')
|
||||
|
||||
def test_no_remainder(self):
|
||||
try:
|
||||
r = self.app_.get('/eater')
|
||||
|
|
Loading…
Reference in New Issue