Code

Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#1192 closed enhancement (wontfix)

[patch] Make urlresolver configureable

Reported by: django@… Owned by: adrian
Component: Core (Other) Version: master
Severity: normal Keywords:
Cc: django@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Currently the urlresolver is fix in the http.base module, which doesn't allow to customize how url's get resolved.
This patch implements a new config variable URL_RESOLVER which points to a class that will be used for resolving the url, makeing it easy to customize the behaviour of the django installation. For example, you could easy implement a weblog hosting where USER.example.org ist the weblog of the user, without touching apache. Or even use a database driven resolver.
The class will be initialized a little bit different then the current RegexURLResolver, because the request object is very usefull for a resolver class.

This patch also implements a HostURLResolver which also matches the hostname through a regular expression.
Note: The urlpatterns a different for this resolver:

urlpatterns = (
    (r'bla', patterns('',
          ...
    )),
    (r'^localhost$', patterns('',
         # Uncomment this for admin:
         (r'^admin/', include('django.contrib.admin.urls.admin')),
    )),
)

But it's for more advanced yours anyway, but I think it will be usefull for many people. The HostURLResolver is not that big, so i put it into core.urlresolvers.

Attachments (3)

django_urlresolve_patch.diff (8.6 KB) - added by django@… 8 years ago.
patch v1
url_resolver2.diff (4.5 KB) - added by django@… 8 years ago.
stripped down version of the patch + some changes to regexp urlresolver that allows easier customizations in custom resolvers
url_resolver3.diff (4.5 KB) - added by django@… 8 years ago.
stripped down version of the patch + some changes to regexp urlresolver that allows easier customizations in custom resolvers. fixed typo

Download all attachments as: .zip

Change History (11)

Changed 8 years ago by django@…

patch v1

comment:1 Changed 8 years ago by adrian

  • priority changed from high to normal

comment:2 Changed 8 years ago by anonymous

  • Cc django@… added

comment:3 Changed 8 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to closed

I'm closing this as a wontfix for now, but people can feel free to make this patch to their own code.

comment:4 Changed 8 years ago by django@…

If i would strip down the patch to the absolut required changes, would possible to reopen and check it in ?
It's not that it's useless, i think it is usefull for many people not only me. People already asked on the mailing lists how to make subdomain specific resolvers. In my opinion it's a design flaw to have only possible way to resolve urls in a very flexible framework.

Changed 8 years ago by django@…

stripped down version of the patch + some changes to regexp urlresolver that allows easier customizations in custom resolvers

Changed 8 years ago by django@…

stripped down version of the patch + some changes to regexp urlresolver that allows easier customizations in custom resolvers. fixed typo

comment:5 Changed 8 years ago by anonymous

  • Resolution wontfix deleted
  • Status changed from closed to reopened

comment:6 Changed 8 years ago by adrian

  • Resolution set to wontfix
  • Status changed from reopened to closed

comment:7 Changed 6 years ago by tclineks

  • Version changed from magic-removal to SVN

Could this be reopened for discussion?

It's a fairly simple change that seems to fit the design philosophies and would eliminate some patchqueues against core.

comment:8 Changed 5 years ago by jholster

A vote for this. Host is part of URL and thus should be available in urlpatterns.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.