I've this line during my wsgi.conf file:

WSGIScriptAlias /trunk "c:/app/trunk/app.wsgi"

Within my django configurations file, I have to be aware of alias "/trunk" to obtain LOGIN_Hyperlink to work correctly. How do i retrieve this value from the apache configurations?

Thanks! Pete

Access the initial WSGI environ dictionary for any specific request and research the 'SCRIPT_NAME' variable. The need for this is actually the notional mount point for that WSGI application as specified when utilizing WSGIScriptAlias. Setting it up with the per request atmosphere is really the only method of doing the work instantly. You can't reach it from outdoors of the request and tthere shouldn't be real need to do that.

By privileges, Django ought to provide a means of instantly getting the mount reason for the applying placed into set up Web addresses for example that. You need to possibly mention the problem around the official Django customers list rather if you fail to find the clear way of doing the work as possibly a general change in Django is required.

Since you need to get yourself a value in the Apache configuration, I suppose the only real factor you should do is browse the file and process it.

Something similar to (presuming your configurations.py lives within the same directory as wsgi.conf):

try:
    f = open('wsgi.conf', 'r')
    LOGIN_URL=[line for line in f.readlines() if 'WSGIScriptAlias' in line][0].split()[1]
finally:
    f.close()

Catching the best when the file isn't there can be advisable too.


Edit after your comment: Ah, I see what you're attempting to do. This thread might be useful to understand why using os.environ will not work. The choice they present will not assist you to though:

The bottom line is, the apache SetEnv is not setting values along the way atmosphere that os.environ signifies. Rather SetEnv is setting values poor the WSGI request.

In your code you are able to reference that context at request.environ:

def myView(request): 
    tier = request.environ['TIER'] 

It's me again. Due to what Apache's SetEnv does, I do not think you'll have the variable in configurations.py. It appears parsing the file remains the only option.

Further Edit: Another alternative - are you able to base your choice around the host title?

 #settings.py
 import socket

 production_servers = { 'server1.com': '/trunk...',
                        'server2.com': '/trunk_2...' }

 LOGIN_URL=production_servers[ socket.gethostname() ]    

This completely sidesteps the data found in apache configuration.