Commits

Andriy Kornatskyy committed 977ae70

Any values from the path match override extra parameters passed during initialization; eliminated merge function from utils module.

  • Participants
  • Parent commits 02d881f

Comments (0)

Files changed (4)

File doc/userguide.rst

         ('posts', latest_posts, {'blog_id': 100})
     ]
 
-Note, that any non-empty values from the path match override extra parameters
-passed during initialization.
+Note, that any values from the path match override extra parameters passed
+during initialization.
 
 ``url`` helper
 --------------

File src/wheezy/routing/regex.py

 
 import re
 
-from wheezy.routing.utils import merge
 from wheezy.routing.utils import outer_split
 
 
         m = self.regex.match(path)
         if m:
             kwargs = m.groupdict()
-            return (m.end(), merge(self.kwargs.copy(), kwargs))
+            return (m.end(), dict(self.kwargs, **kwargs))
         return -1, None
 
     def path_with_kwargs(self, values=None):

File src/wheezy/routing/router.py

 
 from wheezy.routing.builders import build_route
 from wheezy.routing.config import route_builders as default_route_builders
-from wheezy.routing.utils import merge
 from wheezy.routing.utils import route_name
 
 
                     if not kwargs:
                         return handler, kwargs_inner
                     if kwargs_inner:
-                        kwargs = kwargs.copy()
-                        merge(kwargs, kwargs_inner)
+                        kwargs = dict(kwargs, **kwargs_inner)
                     return handler, kwargs
         return None, {}
 

File src/wheezy/routing/utils.py

     return RE_CAMELCASE_TO_UNDERSCOPE_2.sub(r'\1_\2', s).lower()
 
 
-def merge(d1, d2):
-    """ Update ``d1`` from ``d2`` only if a value in ``d2``
-        is evaluated to boolean True.
-
-        >>> d1 = dict(a=1,b=None,c=2, d=3)
-        >>> d2 = dict(a=None,b=2,c=1, e=4)
-        >>> sorted(merge(d1, d2).items())
-        [('a', 1), ('b', 2), ('c', 1), ('d', 3), ('e', 4)]
-    """
-    #d1.update(((k, v) for k, v in d2.iteritems() if v))
-    #d1.update(((k, d2[k]) for k in d2 if d2[k]))
-    #d1.update([(k, v) for k, v in iteritems(d2) if v])
-    d1.update([(k, v) for k, v in d2.items() if v])
-    return d1
-
-
 def outer_split(expression, sep='()'):
     """ Splits given ``expression`` by outer most separators.