Commits

Anonymous committed ea6a17d

Fixes bug in routing.Map.update

  • Participants
  • Parent commits 18c6734

Comments (0)

Files changed (1)

File xmppflask/routing.py

         self.endpoint = endpoint
         self.greediness = 0
         self.redirect_to = redirect_to
-        
+
         self._trace = None
         self._weights = None
         self._converters = None
         self._regex = None
-        
+
         if defaults is not None:
             self.arguments = set(map(str, defaults))
         else:
             if self.defaults is not None:
                 result.update(self.defaults)
             return result
-    
+
     def build(self, values):
         """
         :internal:
                     return False
 
         return True
-    
+
     def __repr__(self):
         if self.map is None:
             return u'<%s (unbound)>' % self.__class__.__name__
             u''.join(tmp),
             self.endpoint
         )
-    
+
     def match_compare(self, other):
         """Compare this object with another one for matching.
-        Needed to match "hello world" rule before "hello" rule ("hello" 
+        Needed to match "hello world" rule before "hello" rule ("hello"
         must be later in search/match order).
 
         :internal:
 
 class Map(object):
     """Map of routes and their handlers"""
-    
+
     #: for more on converters see http://werkzeug.pocoo.org/docs/routing/
     default_converters = ImmutableDict(DEFAULT_CONVERTERS)
-    
+
     def __init__(self, rules=None, converters=None):
         self._rules = []
         self._rules_by_endpoint = {}
         self._remap = True
-        
+
         self.converters = self.default_converters.copy()
         if converters:
             self.converters.update(converters)
         for rulefactory in rules or ():
             self.add(rulefactory)
-    
+
     def add(self, rulefactory):
         """Add a new rule to the map and bind it.
-        
+
         :param rule: a :class:`Rule`
         """
         for rule in rulefactory.get_rules(self):
     def bind_to_environ(self, environ):
         # TODO if needed (if routes will be request-specific somehow)
         return self.bind(message=environ.get('MESSAGE'))
-    
+
     def update(self):
         if self._remap:
             self._rules.sort(lambda a, b: a.match_compare(b))
             for rules in self._rules_by_endpoint.itervalues():
-                rules.sort(lambda a, b: a.build_compare(b))
+                rules.sort(lambda a, b: a.match_compare(b))
             self._remap = False
 
 class MapAdapter(object):
     def __init__(self, map_, message=None):
         self.message = message or u''
         self.map = map_
-    
+
     def match(self, message=None, return_rule=False):
         """The actual match func that is used to get endpoint (or rule) and parameters
         to call (or use somehow).
             else:
                 return rule.endpoint, rv
         raise NotFound()
-    
+
     def build(self, endpoint, values=None):
         """Building messages that suite certain endpoint with valutes (params).
 
-        In XMPP world it might be not as must-have feature, but still it's 
+        In XMPP world it might be not as must-have feature, but still it's
         needed and nice.
         """
         self.map.update()
                               if v is not None)
         else:
             values = {}
-        
+
         rv = self._partial_build(endpoint, values)
         if rv is None:
             raise BuildError(endpoint, values)