The idea is I would like to set up a production (prod) and pre-
production (preprod) and have preprod updated and unit tests run
everytime I commit changes to the SVN repo from my local machine (this
can be easily done with svn-hooks).
No problems so far, however what worries me is how to solve the
settings riddle - I would like to have them dynamically imported
depending of which environment (in this case it's simply another
directory on my webserver) it is run on.
So I had the concept to tag each environment with some marker file
like "__DEV", "__PREPROD", "__PROD" and import specific settings from
inside the main settings.py, depending on which tag-file exists in my
cwd. Didn't succed, but wait, there's more. As I said, each
environment is configured to different directory, so I have symlinks
to site-packages/myapp for PROD (which is myapp.com:80) and site-
packages/myapp_preprod for PREPROD (myapp.com:8080).
Then I realised, that even if I get the dynamic-import issue solved,
the preprod app will work with hardcoded "myapp." module instead of
"myapp_preprod." for views dispatching (urls.py).
Are there any hacks or, preferably, some simple and obvious
solutions ;-) to accomplish my goal?
Much love for your feedback.
Take care,
Adam
May be this is simple enough (if I understand your problem
correctly ;)
1. Don't add myapp_* to site-packages at all. Instead keep them in two
directory roots say /home/apps/prod and /home/apps/preprod. Similarly,
you can have two different settings files for the two environments.
2. In your Apache vhost config for myapp.com:80, add /home/apps/prod
to the PYTHONPATH setting. And, for myapp.com:8080, add /home/apps/
preprod.
See these two sections in the Django deployment documentation:
http://www.djangoproject.com/documentation/modpython/#basic-configuration
http://www.djangoproject.com/documentation/modpython/#multiple-django-installations-on-the-same-apache
+1
If you're concerned about sharing site-packages and similar between
the envs, have a look at virtualenv, too. (It supercedes workingenv.)
http://pypi.python.org/pypi/virtualenv/