2009/8/11 Mario César Señoranis <[email protected]>

> I was trying to deploy a Django application for managing subdomains as
> specific apps, something like devianart.com for example. that
> username.domain.com trows the user dashboard instead the homepage of the
> website.
>
> So, I came with a solution, to chose the urls.py of the project making a
> difference if the user come from the main domain or a subdomain, if on
> the request I get the subdomain I load just an specific urls.py.
>
> In my 'plans' I need to to create a vhost for the main site, that
> catches the domain.com and www.domain.com, and another vhost that caches
> everything else *.domain.com, both vhost would have the same Information
> Source, to get the load of the urls.py be different I want to set
> something like a *custom* setting for each vhost, creating a Custom
> Environment variable in the SCGI handler.


My approach would be to have two separate vhosts (as you mentioned here)
with two slightly different information sources.  For the subdomain one,
pass manage.py the --settings=[file] command to give it a different
settings.py.  In that file, import all the settings from the default, and
override some variable with the value of the subdomain, obtained by
request.META['HTTP_HOST'], as Pablo suggested.  I'd avoid mucking around
with environment variables entirely if I could avoid it.  The calculation
here is minimal (especially if you use python regexes, which are compiled
only once), especially considering that there is already a decent amount of
overhead in the framework itself.  One string-parsing operation isn't
anything to be concerned about, and if your site has the kind of traffic
where it is, you really shouldn't be using an interpreted language.

-- 
James Pearson
--
The best way to predict the future is to invent it.
 - Alan Kay
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee

Reply via email to