Commits

Vincent Hillenbrink  committed c2cb119

Pass extra PYTHONPATH along to initenv_generic, updated docs

  • Participants
  • Parent commits b0c36c0

Comments (0)

Files changed (3)

 Using Apache mod_wsgi
 =====================
 
-Should you wish to use the local settings in for instance
+Should you wish to use the settings in for instance
 ``settings/env/staging.py``, simply copy the example
 ``mysite/deploy/development.wsgi`` to ``mysite/deploy/staging.wsgi``,
-or make staging.wsgi a symlink. Then add something like this to
+or make staging.wsgi a symlink (if your Apache configuration allows
+it, which is normally the case). Next, add something like this to
 your httpd.conf::
 
     WSGIScriptAlias / /Users/spanky/repos/django-environments/mysite/deploy/staging.wsgi
 
-The identifier 'staging' in staging.wsgi will automatically make sure
-settings.env.staging is used. Create other .wsgi files for other environment
-settings.
+And restart Apache. The identifier 'staging' in staging.wsgi will
+automatically make sure settings.env.staging is used. Create other
+.wsgi files for other environment settings.
 
 Refer to the source of the provided WSGI script to see how specific
 directories, like a virtualenv site-packages directory, can be
 Automatic generation of local wsgi links and settings file
 ==========================================================
 
-Alternatively, activate an environment - either directly via your
+If you want your WSGI setup done as quickly as possible, do as
+follows. Activate an environment - either directly via your
 ``scripts/initenv`` or through virtualenv - and execute
 ``scripts/setup_local_wsgi.sh <environment>``, e.g.::
 
  * All .wsgi files in the ``mysite/deploy`` folder are normally
    equal, except for the sys.path configuration. Their respective
    filenames are used to determine which settings to import. If
-   your apache configuration allows it, you could use symlinks
+   your Apache configuration allows it, you could use symlinks
    instead of copies.
  * The scripts directory contains the shell scripts intended to be
    sourced with the ``source`` command, unless they have a '.sh'

File scripts/initenv_example

 DJANGO_SETTINGS=settings.env.development
 SHOW_DJANGO_ENVIRONMENT=yes
 
+# Pass additional directories for sys.path as arguments to
+# initenv_generic, e.g.
+# source $PROJECT_ROOT/scripts/initenv_generic $PROJECT_ROOT/apps
 source $PROJECT_ROOT/scripts/initenv_generic
+
+[ ! $? -eq 0 ] && return 1

File scripts/initenv_generic

 
 # Check Django project as well
 [ -z "$DJANGO_PROJECT" ] && \
-    echo "Variable DJANGO_PROJECT not set or empty" 2>&1 && return 1
+    echo "Variable DJANGO_PROJECT not set or empty" 2>&1 && _deactivate && return 1
 [ ! -d "$PROJECT_ROOT/$DJANGO_PROJECT" ] && \
     echo "Variable DJANGO_PROJECT does not identify a readable directory within $PROJECT_ROOT" 2>&1 && \
     _deactivate && return 1
     DJANGO_SETTINGS_MODULE=$DJANGO_PROJECT.settings
 fi
 
-# Set the PYTHONPATH to include PROJECT_ROOT
+# Set the PYTHONPATH to include PROJECT_ROOT; assume first argument are additional directories
 _OLD_PYTHONPATH=$PYTHONPATH
-PYTHONPATH=$PROJECT_ROOT:$PYTHONPATH
+PYTHONPATH=$PROJECT_ROOT:$1:$PYTHONPATH
 
 export PROJECT_ROOT DJANGO_PROJECT PYTHONPATH DJANGO_SETTINGS_MODULE