summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2013-11-18 11:53:18 -0800
committerBen Bangert <ben@groovie.org>2013-11-18 11:53:18 -0800
commit1f82563b14861a018ccc598d643c3d6b9045fdc2 (patch)
treea88dd18020eadc473a39976ef1ccff1c6f94d1c4
parent802e76ccb4b8b0b848b8a35d921b389a696009f1 (diff)
parentb36017431dab2f9ca9f1960f006bf8d1c2c3cb4c (diff)
downloadroutes-1f82563b14861a018ccc598d643c3d6b9045fdc2.tar.gz
Merge pull request #4 from YorikSar/subcollections_fix
Let submappers' children have their own controllers.
-rw-r--r--routes/mapper.py2
-rw-r--r--tests/test_functional/test_submapper.py12
2 files changed, 14 insertions, 0 deletions
diff --git a/routes/mapper.py b/routes/mapper.py
index bfcea4a..ecabe89 100644
--- a/routes/mapper.py
+++ b/routes/mapper.py
@@ -160,6 +160,8 @@ class SubMapper(SubMapperParent):
elif key in kwargs:
if isinstance(value, dict):
newkargs[key] = dict(value, **kwargs[key]) # merge dicts
+ elif key == 'controller':
+ newkargs[key] = kwargs[key]
else:
newkargs[key] = value + kwargs[key]
else:
diff --git a/tests/test_functional/test_submapper.py b/tests/test_functional/test_submapper.py
index 2efcd94..1df97a6 100644
--- a/tests/test_functional/test_submapper.py
+++ b/tests/test_functional/test_submapper.py
@@ -142,6 +142,18 @@ class TestSubmapper(unittest.TestCase):
eq_(True, r.conditions['sub_domain'])
eq_(requirement, r.reqs)
+ def test_subsubmapper_with_controller(self):
+ m = Mapper()
+ col1 = m.collection('parents', 'parent',
+ controller='col1',
+ member_prefix='/{parent_id}')
+ # NOTE: If one uses functions as controllers, the error will be here.
+ col2 = col1.member.collection('children', 'child',
+ controller='col2',
+ member_prefix='/{child_id}')
+ match = m.match('/parents/1/children/2')
+ eq_('col2', match.get('controller'))
+
if __name__ == '__main__':
unittest.main()