[BangPypers] Can two django projects be made to communicate to each other
Siddharta G
siddharta.lists at gmail.com
Sun Dec 5 09:53:27 CET 2010
Your apache config can be something like this
<Location "/path1/">
SetHandler python-program
PythonHandler django_project_1_frontend
PythonInterpreter django_project_1
PythonOption django.root /path1
SetEnv DJANGO_SETTINGS_MODULE apps.settings
PythonDebug On
PythonPath "['C:/Projects/toolsforagile_common/Scripts'] + sys.path"
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \
\.(?:exe|t?gz|zip|gz2|sit|rar)$ no-gzip dont-vary
</Location>
<Location "/path2/">
SetHandler python-program
PythonHandler django_project_2_frontend
PythonInterpreter django_project_2
PythonOption django.root /path2
SetEnv DJANGO_SETTINGS_MODULE apps.settings
PythonDebug On
PythonPath "['C:/Projects/toolsforagile_common/Scripts'] + sys.path"
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \
\.(?:exe|t?gz|zip|gz2|sit|rar)$ no-gzip dont-vary
</Location>
This will redirect /path1 requests to django_project_1_frontend.py and
/path2 to django_project_2_frontend.py
The PythonInterpreter lines ensure that Apache will create two separate
python instances for each project.
The django_project_x_frontend.py you will need to hook up to the django
project, like this
import site
site.addsitedir("... <add a python paths here>")
site.addsitedir("... <add a python paths here>")
from django.core.handlers.modpython import handler
The way we have configured the layout is that each project is running in its
own virtual environment (using virtualenv). So the site.addsitedir lines
will add the virtualenv paths to before calling the django mod_python
handler.
This way both projects can have their own libraries and site-packages and
won't interfere with each other.
--
Siddharta
More information about the BangPypers
mailing list