Added resolve() and reverse() helper functions to django.core.urlresolvers
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3445 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e5c40514fb
commit
3d02de2713
|
@ -201,3 +201,19 @@ class RegexURLResolver(object):
|
|||
sub_match = self.reverse(viewname, *args, **kwargs)
|
||||
result = reverse_helper(self.regex, *args, **kwargs)
|
||||
return result + sub_match
|
||||
|
||||
def resolve(path, urlconf=None):
|
||||
if urlconf is None:
|
||||
from django.conf import settings
|
||||
urlconf = settings.ROOT_URLCONF
|
||||
resolver = RegexURLResolver(r'^/', urlconf)
|
||||
return resolver.resolve(path)
|
||||
|
||||
def reverse(viewname, urlconf, args=None, kwargs=None):
|
||||
args = args or []
|
||||
kwargs = kwargs or {}
|
||||
if urlconf is None:
|
||||
from django.conf import settings
|
||||
urlconf = settings.ROOT_URLCONF
|
||||
resolver = RegexURLResolver(r'^/', urlconf)
|
||||
return resolver.reverse(viewname, *args, **kwargs)
|
||||
|
|
Loading…
Reference in New Issue