Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactored django.core.urlresolvers a tiny bit

git-svn-id: http://code.djangoproject.com/svn/django/trunk@479 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e67882721d8ae9546575c68c4d3c42dcfa3f8e04 1 parent fcfb8ed
@adrianholovaty adrianholovaty authored
Showing with 7 additions and 9 deletions.
  1. +7 −9 django/core/urlresolvers.py
View
16 django/core/urlresolvers.py
@@ -47,7 +47,7 @@ def get_callback(self):
except AttributeError, e:
raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e))
-class RegexURLResolver:
+class RegexURLResolver(object):
def __init__(self, regex, urlconf_name):
# regex is a string representing a regular expression.
# urlconf_name is a string representing the module containing urlconfs.
@@ -59,7 +59,7 @@ def resolve(self, path):
match = self.regex.search(path)
if match:
new_path = path[match.end():]
- for pattern in self.url_patterns:
+ for pattern in self.urlconf_module.urlpatterns:
try:
sub_match = pattern.resolve(new_path)
except Resolver404, e:
@@ -71,15 +71,13 @@ def resolve(self, path):
raise Resolver404, {'tried': tried, 'path': new_path}
def _get_urlconf_module(self):
- self.urlconf_module = __import__(self.urlconf_name, '', '', [''])
- return self.urlconf_module
+ try:
+ return self._urlconf_module
+ except AttributeError:
+ self._urlconf_module = __import__(self.urlconf_name, '', '', [''])
+ return self._urlconf_module
urlconf_module = property(_get_urlconf_module)
- def _get_url_patterns(self):
- self.url_patterns = self.urlconf_module.urlpatterns
- return self.url_patterns
- url_patterns = property(_get_url_patterns)
-
def _resolve_special(self, view_type):
callback = getattr(self.urlconf_module, 'handler%s' % view_type)
mod_name, func_name = get_mod_func(callback)
Please sign in to comment.
Something went wrong with that request. Please try again.