I previously said people trying to resolve URLs in their code may have difficulty because the DoesNotResolve exception is not raised until the view is run. Just now I thought how it would be done. I think changing resolver.url_patterns to return an iterator to a generator maybe the way to go?
resolver = urlresolvers.RegexURLResolver(r'^/', urlconf)
url_patterns = (pattern for pattern in resolver.url_patterns)
resolver = urlresolvers.RegexURLResolver(r'^/', url_patterns)
while response is None:
callback, callback_args, callback_kwargs = resolver.resolve(
request.path_info)
try:
response = callback(request, *callback_args, **callback_kwargs)
except urlresolvers.DoesNotResolve:
# Continue resolve URLs if the view raises
# urlresolvers.DoesNotResolve exception to indicate
# the url pattern does not match.
continue