-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsgi.py
35 lines (26 loc) · 1.03 KB
/
wsgi.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
# -*- coding: utf-8 -*-
from glob import glob
import os
instance_dir = os.path.dirname(os.path.abspath(__file__))
# auto detect config file
invalids = ['development.ini', 'template.ini', 'who.ini']
filenames = glob(os.path.join(instance_dir, '*.ini'))
filenames = [f for f in filenames if os.path.basename(f) not in invalids]
# you can force it
# filenames = [os.path.join(instance_dir, 'beta.ini')]
if not filenames:
raise OSError((
'No .ini file found. Please add one based on template.ini. '
'See README.rst'))
if len(filenames) > 1:
raise OSError((
'You have more than one possible .ini file. '
'Please remove useless files in %s') % ','.join(filenames))
bin_dir = os.path.join(instance_dir, 'bin')
activate_this = os.path.join(bin_dir, 'activate_this.py')
execfile(activate_this, dict(__file__=activate_this))
from paste.deploy import loadapp
from paste.script.util.logging_config import fileConfig
config_file = filenames[0]
fileConfig(config_file)
application = loadapp('config:%s' % config_file)