summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bangert <ben@groovie.org>2015-01-17 09:48:17 -0800
committerBen Bangert <ben@groovie.org>2015-01-17 09:48:17 -0800
commit24dd9fb4393964673fcfd584d10a30738278af72 (patch)
tree492efe2bc12b09fae5c6659e61798698e219c2f6
parent7690fc1016e56739855435fb54c96acccfa29009 (diff)
parent4b16406b4d389147e6d66062ae1bf722bafcb233 (diff)
downloadroutes-24dd9fb4393964673fcfd584d10a30738278af72.tar.gz
Merge pull request #26 from samdphillips/master
Extract Route creation into separate method
-rw-r--r--CHANGELOG.rst3
-rw-r--r--routes/mapper.py9
2 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 1a1db6d..4b1c50f 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,6 +1,9 @@
Routes Changelog
%%%%%%%%%%%%%%%%
+* Extract Route creation into separate method in Mapper. Subclasses of Route
+ can be created by Mappers now.
+
Release 2.0 (November 17, 2013)
===============================
* Python 3.2/3.3 Support. Fixes Issue #2. Thanks to Alejandro Sánchez for
diff --git a/routes/mapper.py b/routes/mapper.py
index 69984be..018fa7c 100644
--- a/routes/mapper.py
+++ b/routes/mapper.py
@@ -460,6 +460,13 @@ class Mapper(SubMapperParent):
routepath = route.routepath
self.connect(route.name, routepath, **route._kargs)
+ def make_route(self, *args, **kargs):
+ """Make a new Route object
+
+ A subclass can override this method to use a custom Route class.
+ """
+ return Route(*args, **kargs)
+
def connect(self, *args, **kargs):
"""Create and connect a new Route to the Mapper.
@@ -486,7 +493,7 @@ class Mapper(SubMapperParent):
kargs['_explicit'] = self.explicit
if '_minimize' not in kargs:
kargs['_minimize'] = self.minimization
- route = Route(*args, **kargs)
+ route = self.make_route(*args, **kargs)
# Apply encoding and errors if its not the defaults and the route
# didn't have one passed in.