0
|
1 import os
|
|
2 from redirector import Redirector
|
|
3 from paste.httpexceptions import HTTPExceptionHandler
|
|
4 from paste.urlparser import StaticURLParser
|
|
5
|
|
6 def factory(global_conf, **app_conf):
|
|
7 """create a sample redirector"""
|
|
8 assert 'app.directory' in app_conf
|
|
9 directory = app_conf['app.directory']
|
|
10 assert os.path.isdir(directory)
|
|
11 keystr = 'redirector.'
|
|
12 args = dict([(key.split(keystr, 1)[-1], value)
|
|
13 for key, value in app_conf.items()
|
|
14 if key.startswith(keystr) ])
|
|
15 app = StaticURLParser(directory)
|
|
16 redirector = Redirector(app, **args)
|
|
17 return HTTPExceptionHandler(redirector)
|
|
18
|