Merge pull request #164 from ryanpetrello/next
Fix a routing-related bug in RestController. fixes #156
This commit is contained in:
@@ -312,7 +312,7 @@ class Pecan(object):
|
||||
valid_args = valid_args[len(args):]
|
||||
|
||||
# handle wildcard arguments
|
||||
if remainder:
|
||||
if filter(None, remainder):
|
||||
if not argspec[1]:
|
||||
abort(404)
|
||||
args.extend(remainder)
|
||||
|
||||
@@ -863,3 +863,28 @@ class TestRestController(TestCase):
|
||||
r = app.get('/foos/bars/bazs/final/named')
|
||||
assert r.status_int == 200
|
||||
assert r.body == 'NAMED'
|
||||
|
||||
def test_post_with_kwargs_only(self):
|
||||
|
||||
class RootController(RestController):
|
||||
|
||||
@expose()
|
||||
def get_all(self):
|
||||
return 'INDEX'
|
||||
|
||||
@expose('json')
|
||||
def post(self, **kw):
|
||||
return kw
|
||||
|
||||
# create the app
|
||||
app = TestApp(make_app(RootController()))
|
||||
|
||||
r = app.get('/')
|
||||
assert r.status_int == 200
|
||||
assert r.body == 'INDEX'
|
||||
|
||||
kwargs = {'foo': 'bar', 'spam': 'eggs'}
|
||||
r = app.post('/', kwargs)
|
||||
assert r.status_int == 200
|
||||
assert r.namespace['foo'] == 'bar'
|
||||
assert r.namespace['spam'] == 'eggs'
|
||||
|
||||
Reference in New Issue
Block a user