Ticket #7537: dj-urlresolver-patch2.patch
File dj-urlresolver-patch2.patch, 2.9 KB (added by , 16 years ago) |
---|
-
urlresolvers.
old new 198 198 def reverse_helper(self, *args, **kwargs): 199 199 return reverse_helper(self.regex, *args, **kwargs) 200 200 201 class RegexURLResolver(object):201 class BaseRegexURLResolver(object): 202 202 def __init__(self, regex, urlconf_name, default_kwargs=None): 203 # regex is a string representing a regular expression.204 # urlconf_name is a string representing the module containing urlconfs.205 203 self.regex = re.compile(regex, re.UNICODE) 206 self.urlconf_name = urlconf_name 207 self.callback = None 204 self.callback = None # FIXME: why does this class have `callback`? 208 205 self.default_kwargs = default_kwargs or {} 209 206 210 207 def __repr__(self): 211 return '<%s %s %s>' % (self.__class__.__name__, self.urlconf_name, self.regex.pattern)208 return '<%s %s>' % (self.__class__.__name__, self.regex.pattern) 212 209 213 210 def _get_reverse_dict(self): 214 211 if not hasattr(self, '_reverse_dict'): … … 245 242 tried.append(pattern.regex.pattern) 246 243 raise Resolver404, {'tried': tried, 'path': new_path} 247 244 245 def reverse(self, lookup_view, *args, **kwargs): 246 try: 247 lookup_view = get_callable(lookup_view, True) 248 except (ImportError, AttributeError): 249 raise NoReverseMatch 250 if lookup_view in self.reverse_dict: 251 return u''.join([reverse_helper(part.regex, *args, **kwargs) for part in self.reverse_dict[lookup_view]]) 252 raise NoReverseMatch 253 254 255 class RegexURLResolver(BaseRegexURLResolver): 256 def __init__(self, regex, urlconf_name, default_kwargs=None): 257 # regex is a string representing a regular expression. 258 # urlconf_name is a string representing the module containing urlconfs. 259 super(RegexURLResolver, self).__init__(regex, default_kwargs) 260 self.urlconf_name = urlconf_name 261 262 def __repr__(self): 263 return '<%s %s %s>' % (self.__class__.__name__, self.urlconf_name, self.regex.pattern) 264 248 265 def _get_urlconf_module(self): 249 266 try: 250 267 return self._urlconf_module … … 275 292 def resolve500(self): 276 293 return self._resolve_special('500') 277 294 278 def reverse(self, lookup_view, *args, **kwargs): 279 try: 280 lookup_view = get_callable(lookup_view, True) 281 except (ImportError, AttributeError): 282 raise NoReverseMatch 283 if lookup_view in self.reverse_dict: 284 return u''.join([reverse_helper(part.regex, *args, **kwargs) for part in self.reverse_dict[lookup_view]]) 285 raise NoReverseMatch 286 295 # FIXME: this seems to be unused. 287 296 def reverse_helper(self, lookup_view, *args, **kwargs): 288 297 sub_match = self.reverse(lookup_view, *args, **kwargs) 289 298 result = reverse_helper(self.regex, *args, **kwargs)