Amit Upadhyay wrote:
> Hi,
> 
> Wish you all a very happy and fruitful new year!
> 
> Djando URL resolution causes some problem with applications hosted in
> different subdomains. Consider www.example.com <http://www.example.com>
> and blog.example.com <http://blog.example.com>. Both of them are running
> off the same database and share common admin, and so on, but are hosted
> in different subdomain, which causes problem with URL resolution. To
> solve this we can copy the settings file and change ROOT_URLCONF to
> point to different locations. I propose splitting settings.py into
> common_settings.py and www_settings.py. www_settings.py contains
> something equivalent to:
> 
[...]
> 
> What do you think?

I think the right approach would be to make the urlresolver in
handlers.base configurable through a settings variable.
The default value would be something like

URL_RESOLVER = "django.core.urlresolvers.RegexURLResolver"

This would allow to write custom resolvers.
Also a resolver that also checks the hostname would be nice to be
included. it would uses a different ROOT_URLCONF like:

urlpatterns = {
r'www\.bla\.com': patterns('',
        ...
           (r'^admin/', include('django.contrib.admin.urls.admin')),
        )
r'.*\.bla\.com': patterns('',
        ...
        )
}

You could do very nice things with this approach, like using a database
to resolve the url, or even change the other settings depending on the
hostname you resolve...
The speed impact would be minimal and the posibilities enormous.

kindly regards
 Daniel

Reply via email to