1. Ralph Bean
  2. tg-dev

Commits

percious  committed 11474fa

more fixes to dispatch, odict.

  • Participants
  • Parent commits 70ad297
  • Branches default

Comments (0)

Files changed (2)

File tg/controllers/dispatcher.py

View file
  • Ignore whitespace
         tree until we found a method which matches with a default or lookup method.
         """
         orig_url_path = state.url_path
-        if len(remainder):
+        if remainder:
             state.url_path = state.url_path[:-len(remainder)]
         for i in xrange(len(state.controller_path)):
             controller = state.controller
                 if type(last_tried_lookup) != type(new_controller):
                     self._last_tried_abstraction = new_controller
                     state.add_controller(remainder[0], new_controller)
-                    return self._dispatch(state, new_remainder)
+                    dispatcher = getattr(new_controller, '_dispatch', self._dispatch)
+                        
+                    return dispatcher(state, new_remainder)
 
             if self._is_exposed(controller, 'default'):
                 warn('default method is deprecated, please replace with _default', DeprecationWarning)

File tg/util.py

View file
  • Ignore whitespace
             return result
 
 class odict(dict):
-    
+
     def __init__(self, *args, **kw):
         self._ordering = []
         dict.__init__(self, *args, **kw)
-    
+
     def __setitem__(self, key, value):
+        if key in self._ordering:
+            self._ordering.remove(key)
         self._ordering.append(key)
         dict.__setitem__(self, key, value)
-    
+
     def keys(self):
         return self._ordering
-    
+
     def clear(self):
         self._ordering = []
         dict.clear(self)
-        
+
     def getitem(self, n):
         return self[self._ordering[n]]
-    
-    def __slice__(self, a, b, n):
-        return self.values()[a:b:n]
-    
+        
+
+#    def __slice__(self, a, b=-1, n=1):
+#        return self.values()[a:b:n]
+
     def iteritems(self):
         for item in self._ordering:
             yield item, self[item]
-    
+
     def items(self):
         return [i for i in self.iteritems()]
-    
+
     def itervalues(self):
         for item in self._ordering:
             yield self[item]
-        
+
     def values(self):
-        return [i for i in self.values()]
-    
-    def __delete__(self, key):
+        return [i for i in self.itervalues()]
+
+    def __delitem__(self, key):
         self._ordering.remove(key)
-        dict.__delete__(self, key)
-        
+        dict.__delitem__(self, key)
+
     def pop(self):
         item = self._ordering[-1]
         del self[item]
-        self._ordering.remove(item)
-        
+
     def __str__(self):
         return str(self.items())