Wednesday, May 22, 2013

environment variables in virtualenv's postactivate using mod_wsgi

Hi, 

Hope you're well. 

I've added a couple of environment variables to my virtualenv postactivate file, for example:

export DATABASE_USER="root"
export DATABASE_PASSWORD="12345678"

I then assign those variables in my settings.py using os.environ['DATABASE_USER'], for example

DATABASE_USER = os.environ['DATABASE_USER']

Since my Apache virtualhost file contains

WSGIDaemonProcess mysite.local python-path=/my/python/path:/path/to/my/project/venv/lib/python2.7/site-packages
WSGIProcessGroup mysite.local
WSGIScriptAlias / /path/to/my/project/wsgi.py

As I understand it, this tells mod_wsgi to run in daemon mode and which virtualenv to use.
Since it knows which virtualenv to use, I would image it would run postactivate, thereby enabling my environment variables, but this however is not the case. 

Am I doing something wrong? Any suggestions or recommendations are welcome. 

Kind regards,
C

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment