﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
7537	Make RegexURLResolver easier to subclass	Kenneth Arnold	nobody	"Referencing [http://groups.google.com/group/django-developers/browse_thread/thread/e16bcd24f9e27062 the django-developers discussion], here's some simple patches to make the URL resolver easier to customize.

First is a nearly minimal patch to convert the url_patterns property to an accessor, get_url_patterns, to ease subclassing, and make the other methods use that consistently instead of duplicating its functionality. With only this patch you can make your own URL resolver without duplicating code, but it's still not clean.

The second patch cleans up the situation by abstracting the core functionality of a regex URL resolver into {{{BaseRegexURLResolver}}}.

The third patch is an example of how newforms-admin might use this for URL dispatching. I don't have a deep understanding about what's going on, so treat what I did just as an example. Perhaps the cleanest way to accomplish some of what the old ad-hoc resolver did is to override {{{resolve}}}, and if {{{super().resolve}}} returns None, do the ad-hoc stuff.

You'd use a custom resolver in your urlconf like this:

{{{
urlpatterns += [AdminSite(r'^admin/')]
}}}
i.e., like a normal {{{include}}} (at least, what that {{{include}}} looks like under the hood).

The newforms-admin change would be backwards-incompatible, so if people think it's a good idea, it should get a separate ticket.

About the accessor: properties don't inherit well. Could add a {{{url_patterns = property(lambda self: self.get_url_patterns())}}} if that's not too ugly.
"	New feature	closed	Core (URLs)	dev	Normal	invalid	url, urlpatterns, resolver	kenneth.arnold@… eallik@…	Accepted	1	0	1	0	0	0
