1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #4839 -- Added __repr__ methods to URL classes that show the pattern they

contain. Thanks, Thomas Güttler.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@5681 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-07-13 09:14:51 +00:00
parent 92f54aff7a
commit 53e3f76d6e

View File

@ -144,6 +144,9 @@ class RegexURLPattern(object):
self.default_args = default_args or {}
self.name = name
def __repr__(self):
return '<%s %s %s>' % (self.__class__.__name__, self.name, self.regex.pattern)
def add_prefix(self, prefix):
"""
Adds the prefix string to a string-based callback.
@ -205,6 +208,9 @@ class RegexURLResolver(object):
self.default_kwargs = default_kwargs or {}
self._reverse_dict = {}
def __repr__(self):
return '<%s %s %s>' % (self.__class__.__name__, self.urlconf_name, self.regex.pattern)
def _get_reverse_dict(self):
if not self._reverse_dict and hasattr(self.urlconf_module, 'urlpatterns'):
for pattern in reversed(self.urlconf_module.urlpatterns):