forked from nicferrier/multiserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispatcher.py
47 lines (34 loc) · 1.16 KB
/
dispatcher.py
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
"""
A multiserver dispatcher for WooMe.com
"""
from os.path import join as joinpath
import os
def dispatch(path, environ, start_response):
"""Dispatch the wsgi call to the WooMe instance in the specified directory.
This only handles ticket repos of course.
"""
repopath = joinpath(path, "woome")
os.chdir(repopath)
import sys
sys.path += [repopath]
import config.importname
conf = config.importname.get()
cm = __import__("config.%s" % conf, {}, {}, [""])
from os.path import basename
reponame = basename(path).replace("_", "-")
cm.STATIC_URL = 'http://%s.repos.dev.woome.com' % reponame
cm.IMG_URL = 'http://%s.repos.dev.woome.com' % reponame
cm.ENABLE_JS_MINIFY = False
import settings
try:
sys.path = [settings.DJANGO_PATH_DIR] + sys.path
except AttributeError:
pass
import django.core.management
django.core.management.setup_environ(settings)
import django.core.handlers.wsgi
class SpawningDjangoWSGIHandler(django.core.handlers.wsgi.WSGIHandler):
pass
wsgi_handler = SpawningDjangoWSGIHandler()
return wsgi_handler(environ, start_response)
# End