简体   繁体   English

Twisted上有多个虚拟主机的Django?

[英]Django on Twisted with multiple virtual hosts?

I have a django website that I am hosting on twisted via the django WSGIHandler as described here - http://www.clemesha.org/blog/Django-on-Twisted-using-latest-twisted-web-wsgi 我有一个Django的网站,这里所描述的,我就通过Django的WSGIHandler扭曲托管- http://www.clemesha.org/blog/Django-on-Twisted-using-latest-twisted-web-wsgi

All seems OK up to the point where I want to add an extra "site" configuration to my django site using the django Sites framework. 一切似乎都可以,直到我想使用django Sites框架向django站点添加额外的“站点”配置。 Doing so, I add an extra settings.py file for the new site and that seems to work. 这样做,我为新站点添加了一个额外的settings.py文件,这似乎可行。

What I then want to do is use the twisted NameVirtualHost class to be able to direct one domain (say site1.example.com) to the first settings file, then use another domain (say site2.example.com) to use the second settings file. 然后,我要做的是使用扭曲的NameVirtualHost类将一个域(例如site1.example.com)定向到第一个设置文件,然后使用另一个域(例如site2.example.com)来使用第二个设置文件。 This works with Apache & mod_wsgi. 这适用于Apache和mod_wsgi。

The problem I face is that the twisted code can only access one django environment at a time. 我面临的问题是,扭曲的代码一次只能访问一个Django环境。 If I call setup_environ with the first settings file and setup a host for the first domain, a subsequent call to setup_environ will replace the settings file in use so therefore only one set of settings can be used at one time. 如果我使用第一个设置文件调用setup_environ并为第一个域设置主机,则随后对setup_environ的调用将替换正在使用的设置文件,因此一次只能使用一组设置。

Any ideas how to proceed? 任何想法如何进行?

Gave up on this in the end. 最后放弃这个。 Looks like you cannot easily access 2 Django environments within the same twisted instance. 看起来您无法在同一个扭曲实例中轻松访问2个Django环境。 I think it would require multiple instances of twisted with a reverse proxy or some sort of multiprocess hacking - either way its not worth the effort for me so I'm going to try something else... 我认为这将需要使用反向代理或某种形式的多进程黑客来扭曲多个实例-任一种方式对我来说都不值得,所以我将尝试其他方法...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM