summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Phillips <samdphillips@gmail.com>2014-01-20 13:19:13 -0800
committerSam Phillips <samdphillips@gmail.com>2014-01-20 13:21:44 -0800
commit1bfd8901cd8ec9181e40e8e8b76980f8a0705a65 (patch)
tree633353e7b3a2713138153600a40b521b409513bf
parent7690fc1016e56739855435fb54c96acccfa29009 (diff)
downloadroutes-1bfd8901cd8ec9181e40e8e8b76980f8a0705a65.tar.gz
Extract Route creation into separate method
Allow a Mapper subclass to use a different Route implementation.
-rw-r--r--routes/mapper.py9
1 files changed, 8 insertions, 1 deletions
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.