aboutsummaryrefslogtreecommitdiff
path: root/rpkid/portal-gui/rpki.wsgi.in
blob: 3d1983497d6a8bf1b32a8516131b590777e86f26 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Copyright (C) 2010, 2011  SPARTA, Inc. dba Cobham Analytic Solutions
# Copyright (C) 2012  SPARTA, Inc. a Parsons Company
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

# This is an example wsgi application for use with mod_wsgi and apache.

__version__ = '$Id$'

VIRTUAL_ENV = '@VIRTUAL_ENV@'

import os
import os.path
import sys

old_sys_path = list(sys.path)

def walk_error(e):
    'This function is invoked when os.walk() needs to report an error'
    print >>sys.stderr, 'error reading %s: %s' % (e.filename, e)

# When used with virtualenv, specify the location of the python modules to use
if VIRTUAL_ENV:
    d = os.path.join(VIRTUAL_ENV, 'lib')
    # locate the site-packages directory
    for dp, dn, fn in os.walk(os.path.join(VIRTUAL_ENV, 'lib'),
                              onerror=walk_error):
        if 'site-packages' in dn:
            d = os.path.join(dp, 'site-packages')
            import site
            site.addsitedir(d)
            break

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
sys.path.insert(1, '@PYTHONPATH@')

# reorder sys.path to place newly added directories at the head of the path.
# this is necessary so that the packages in the virtualenv site-packages are
# used rather than the system site-packages.
new_sys_path = []
for elt in list(sys.path):
    if elt not in old_sys_path:
        new_sys_path.append(elt)
        sys.path.remove(elt)
sys.path[:0] = new_sys_path

print >>sys.stderr, sys.path

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

# vim:ft=python