El lun, 17-08-2009 a las 14:12 -0700, James Pearson escribió: > 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.
Thanks, I get realize that using the environment variable isn't such a *good* idea. I am doing something like your advice. Instead have just /project/manage.py I create /projects/main/manage.py /projects/subdomains/manage.py I load the same settings, but override some as the URL_CONF, so I get two information server for each project that loads the same DB and share some apps and give the *.domain.com to the subdomains project and www.domain.com to the main project, with that and a middleware that calculate the subdomain name on each http request, all the project get done :) I am still curious about the Environment Variable, cause It doesn't behave as I expected. But it's not my concern any more. :) Best Regards > -- > James Pearson > -- > The best way to predict the future is to invent it. > - Alan Kay -- Mario César Señoranis Ayala Twitter: http://twitter.com/mariocesar_bo Arte: http://mariocesar.deviantart.com Blog Software Libre: http://softwarelibre.org.bo/mariocesar Noticias Compartidas: http://tinyurl.com/mariocesar-shared-news
signature.asc
Description: Esto es una parte de mensaje firmado digitalmente
_______________________________________________ Cherokee mailing list [email protected] http://lists.octality.com/listinfo/cherokee
