Ticket #7537: dj-urlresolver-patch1.patch
File dj-urlresolver-patch1.patch, 1.9 KB (added by , 16 years ago) |
---|
-
urlresolvers.py
206 206 self.urlconf_name = urlconf_name 207 207 self.callback = None 208 208 self.default_kwargs = default_kwargs or {} 209 self._reverse_dict = {}210 209 211 210 def __repr__(self): 212 211 return '<%s %s %s>' % (self.__class__.__name__, self.urlconf_name, self.regex.pattern) 213 212 214 213 def _get_reverse_dict(self): 215 if not self._reverse_dict and hasattr(self.urlconf_module, 'urlpatterns'): 216 for pattern in reversed(self.urlconf_module.urlpatterns): 214 if not hasattr(self, '_reverse_dict'): 215 # FIXME: now we'll fail if no URL patterns are defined. I 216 # think that's a good thing, though. 217 # Was: and hasattr(self.urlconf_module, 'urlpatterns'): 218 self._reverse_dict = {} 219 for pattern in reversed(self.get_url_patterns()): 217 220 if isinstance(pattern, RegexURLResolver): 218 221 for key, value in pattern.reverse_dict.iteritems(): 219 222 self._reverse_dict[key] = (pattern,) + value … … 228 231 match = self.regex.search(path) 229 232 if match: 230 233 new_path = path[match.end():] 231 for pattern in self. urlconf_module.urlpatterns:234 for pattern in self.get_url_patterns(): 232 235 try: 233 236 sub_match = pattern.resolve(new_path) 234 237 except Resolver404, e: … … 256 259 return self._urlconf_module 257 260 urlconf_module = property(_get_urlconf_module) 258 261 259 def _get_url_patterns(self):262 def get_url_patterns(self): 260 263 return self.urlconf_module.urlpatterns 261 url_patterns = property(_get_url_patterns)262 264 263 265 def _resolve_special(self, view_type): 264 266 callback = getattr(self.urlconf_module, 'handler%s' % view_type)