Permalink
Browse files

Added resolve() and reverse() helper functions to django.core.urlreso…

…lvers

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3445 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
adrianholovaty committed Jul 25, 2006
1 parent e5c4051 commit 3d02de27138b420825156f0631a32cdcda2d91aa
Showing with 16 additions and 0 deletions.
  1. +16 −0 django/core/urlresolvers.py
@@ -201,3 +201,19 @@ def reverse_helper(self, viewname, *args, **kwargs):
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)

0 comments on commit 3d02de2

Please sign in to comment.