Merge pull request #164 from ryanpetrello/next

Fix a routing-related bug in RestController.  fixes #156
This commit is contained in:
markmcclain
2013-01-18 12:35:31 -08:00
2 changed files with 26 additions and 1 deletions

View File

@@ -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)

View File

@@ -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'