4

Is there a way to pass extra arguments to WSGIScriptAlias? For example:

WSGIScriptAlias / /foo/bar/wsgi.py but what I want is:

WSGIScriptAlias / /foor/bar/wsgi.py baz

Edit for clarification:

I have a Django project with multiple configurations based on the environment in which it is running (cloud-based deployment). Currently, I'm loading configuration based on hostname (which I'm not overly happy with because it doesn't lend itself well to testing multiple configs on one machine without changing the system's hostname). So, another solution would be to pass in command line arguments to the application and load the config in the WSGI entry point, which is relatively trivial when running the dev server, but I'm not aware of any way to do it via Apache/WSGI.

1
  • No, but then I don't know what the original problem you are trying to solve is and what that is meant to do? Simply asking whether that will work doesn't tell us anything about what you need and so we can't tell you how to do what you want? Commented Nov 20, 2012 at 1:19

2 Answers 2

4

First up, ensure you are using daemon mode, it is preferred anyway.

Then inside of your WSGI script file you can do:

import mod_wsgi

process_group = mod_wsgi.process_group

You can then use the name of the process group as a way of distinguishing which configuration.

In other words, use the name of the daemon process group you choose to use in the Apache configuration file as the distinguishing factor.

Sign up to request clarification or add additional context in comments.

Comments

0

If you are using mod_wsgi, you may take advantage of envvars options when setting up.

For example:

mod_wsgi-express start-server ./my-wsgi.py --port 8200 --envvars-script /home/user/envvars_localhost.sh

in the envvars file "envvars_localhost.sh", set some needed parameter:

#!/bin/bash
export MOD_WSGI_VARIABLE='config1'

then at runtime your ./my-wsgi.py can reference the data:

mylocalConfigValue = os.environ['MOD_WSGI_VARIABLE']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.