summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2015-01-17 14:16:52 -0800
committerBen Bangert <ben@groovie.org>2015-01-17 14:16:52 -0800
commit4baf95808cbbab4db6ee2e6e9a54109b9b23a3f3 (patch)
tree4305f34de8f08f14c8db830311a1ad2efe825975
parentdcdb3f39a072dbb8fcc7bf8365be05af5ca4b4e1 (diff)
downloadroutes-4baf95808cbbab4db6ee2e6e9a54109b9b23a3f3.tar.gz
* Printing a mapper now includes the Controller/action parameters from the
route. Fixes #11.
-rw-r--r--CHANGELOG.rst2
-rw-r--r--routes/mapper.py5
-rw-r--r--tests/test_units/test_mapper_str.py8
3 files changed, 9 insertions, 6 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 3f79c37..dc2aa4a 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -3,6 +3,8 @@ Routes Changelog
Release 2.1 (**dev**)
=====================
+* Printing a mapper now includes the Controller/action parameters from the
+ route. Fixes #11.
* Fix regression that didn't allow passing in params 'host', 'protocol', or
'anchor'. They can now be passed in with a trailing '_' as was possible
before commit d1d1742903fa5ca24ef848a6ae895303f2661b2a. Fixes #7.
diff --git a/routes/mapper.py b/routes/mapper.py
index 8979253..ea55cda 100644
--- a/routes/mapper.py
+++ b/routes/mapper.py
@@ -400,8 +400,9 @@ class Mapper(SubMapperParent):
else:
return ''
- table = [('Route name', 'Methods', 'Path')] + \
- [(r.name or '', format_methods(r), r.routepath or '')
+ table = [('Route name', 'Methods', 'Path', 'Controller', 'action')] + \
+ [(r.name or '', format_methods(r), r.routepath or '',
+ r.defaults.get('controller', ''), r.defaults.get('action', ''))
for r in self.matchlist]
widths = [max(len(row[col]) for row in table)
diff --git a/tests/test_units/test_mapper_str.py b/tests/test_units/test_mapper_str.py
index e6cea1b..bc2068a 100644
--- a/tests/test_units/test_mapper_str.py
+++ b/tests/test_units/test_mapper_str.py
@@ -9,10 +9,10 @@ class TestMapperStr(unittest.TestCase):
m.connect('entry', '/entries/{id}', controller='entry', action='show')
expected = """\
-Route name Methods Path
+Route name Methods Path Controller action
/{controller}/{action}
-entries /entries
-entry /entries/{id}"""
-
+entries /entries entry index
+entry /entries/{id} entry show"""
+
for expected_line, actual_line in zip(expected.splitlines(), str(m).splitlines()):
assert expected_line == actual_line.rstrip()