diff options
author | Davanum Srinivas <davanum@gmail.com> | 2016-03-29 11:36:00 -0400 |
---|---|---|
committer | Davanum Srinivas <davanum@gmail.com> | 2016-03-29 15:35:41 -0400 |
commit | 21bc2ea57c5d418f37c528258ebbcf2335e009b6 (patch) | |
tree | 57fdd680824956147b0519a2d0393645320fbf28 /routes | |
parent | 3d87edf1744d0ce6da1feba3a7eddcb31a9b4de4 (diff) | |
download | routes-21bc2ea57c5d418f37c528258ebbcf2335e009b6.tar.gz |
Tolerate older usage with mandatory routename and optional path
With the following review:
https://github.com/bbangert/routes/commit/0a417004be7e2d950bdcd629ccf24cf9f56ef817
Routes 2.3 has changed the function signature to mandate
path in addition to routename for the connect method.
In this patch, we try to get back to path being optional by
checking the length of the args list. No other change in
logic.
This hopefully fixes the problem reported here:
https://github.com/bbangert/routes/issues/64
Add an entry in Changelog as well.
Diffstat (limited to 'routes')
-rw-r--r-- | routes/mapper.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/routes/mapper.py b/routes/mapper.py index 06f09f2..48bba45 100644 --- a/routes/mapper.py +++ b/routes/mapper.py @@ -162,25 +162,25 @@ class SubMapper(SubMapperParent): self.formatted = True self.add_actions(actions or [], **kwargs) - def connect(self, *args, **kwargs): + def connect(self, routename, path=None, **kwargs): newkargs = {} - # newargs = args - routename, path = args + _routename = routename + _path = path for key, value in six.iteritems(self.kwargs): if key == 'path_prefix': - if len(args) > 1: + if path is not None: # if there's a name_prefix, add it to the route name # and if there's a path_prefix - path = ''.join((self.kwargs[key], args[1])) + _path = ''.join((self.kwargs[key], path)) else: - path = ''.join((self.kwargs[key], args[0])) + _path = ''.join((self.kwargs[key], routename)) elif key == 'name_prefix': - if len(args) > 1: + if path is not None: # if there's a name_prefix, add it to the route name # and if there's a path_prefix - routename = ''.join((self.kwargs[key], args[0])) + _routename = ''.join((self.kwargs[key], routename)) else: - routename = None + _routename = None elif key in kwargs: if isinstance(value, dict): newkargs[key] = dict(value, **kwargs[key]) # merge dicts @@ -197,7 +197,7 @@ class SubMapper(SubMapperParent): if key not in self.kwargs: newkargs[key] = kwargs[key] - newargs = (routename, path) + newargs = (_routename, _path) return self.obj.connect(*newargs, **newkargs) def link(self, rel=None, name=None, action=None, method='GET', |