summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Petrello <lists@ryanpetrello.com>2013-01-11 12:47:47 -0500
committerRyan Petrello <lists@ryanpetrello.com>2013-01-11 12:47:47 -0500
commitfb6a5713af30a9ba945ef83dd408fe84ce924447 (patch)
tree025e52d26e60d504c15e65a6926c2d0c8e1e9486
parent66707c4082381f8037b9113a6bfb4678cb22c5f4 (diff)
downloadpecan-fb6a5713af30a9ba945ef83dd408fe84ce924447.tar.gz
Fix a routing-related bug in RestController. fixes #156
-rw-r--r--pecan/core.py2
-rw-r--r--pecan/tests/test_rest.py24
2 files changed, 25 insertions, 1 deletions
diff --git a/pecan/core.py b/pecan/core.py
index fb741a9..fda40b7 100644
--- a/pecan/core.py
+++ b/pecan/core.py
@@ -307,7 +307,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)
diff --git a/pecan/tests/test_rest.py b/pecan/tests/test_rest.py
index 4935c00..1bad77f 100644
--- a/pecan/tests/test_rest.py
+++ b/pecan/tests/test_rest.py
@@ -863,3 +863,27 @@ 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.body == dumps(kwargs)