|
a/ForgeClassic/sfx/middleware.py |
|
b/ForgeClassic/sfx/middleware.py |
|
... |
|
... |
16 |
self.environ_values = {
|
16 |
self.environ_values = {
|
17 |
'allura.sfx_session_manager': SFXSessionMgr(),
|
17 |
'allura.sfx_session_manager': SFXSessionMgr(),
|
18 |
}
|
18 |
}
|
19 |
self.environ_values['allura.sfx_session_manager'].setup_sessiondb_connection_pool(
|
19 |
self.environ_values['allura.sfx_session_manager'].setup_sessiondb_connection_pool(
|
20 |
config)
|
20 |
config)
|
21 |
self.configure_databases(config)
|
21 |
configure_databases(config)
|
22 |
|
|
|
23 |
def configure_databases(self, config):
|
|
|
24 |
M.site_meta.bind = engine_from_config(h.config_with_prefix(config, 'site_db.'))
|
|
|
25 |
M.mail_meta.bind = engine_from_config(h.config_with_prefix(config, 'mail_db.'))
|
|
|
26 |
M.task_meta.bind = engine_from_config(h.config_with_prefix(config, 'task_db.'))
|
|
|
27 |
M.epic_meta.bind = engine_from_config(h.config_with_prefix(config, 'epic_db.'))
|
|
|
28 |
# Configure SFX Database Tables
|
|
|
29 |
T = M.tables
|
|
|
30 |
# Alexandria Tables
|
|
|
31 |
T.mail_group_list = Table('mail_group_list', M.site_meta, autoload=True)
|
|
|
32 |
T.groups = Table(
|
|
|
33 |
'groups', M.site_meta, autoload=True,
|
|
|
34 |
include_columns=['group_id', 'group_name', 'status'])
|
|
|
35 |
T.mllist_subscriber = Table('mllist_subscriber', M.site_meta, autoload=True)
|
|
|
36 |
T.prweb_vhost = Table('prweb_vhost', M.site_meta, autoload=True)
|
|
|
37 |
T._mysql_auth = t = Table(
|
|
|
38 |
'mysql_auth', M.site_meta, autoload=True,
|
|
|
39 |
)
|
|
|
40 |
T.mysql_auth = select([
|
|
|
41 |
t,
|
|
|
42 |
func.which_user(t.c.modified_by_uid).label('modified_user')]).alias('msql_auth_user')
|
|
|
43 |
# MailDB tables
|
|
|
44 |
T.lists = Table('lists', M.mail_meta, autoload=True)
|
|
|
45 |
# TaskDB Tables
|
|
|
46 |
T.ml_password_change = Table(
|
|
|
47 |
'ml_password_change', M.task_meta, autoload=True)
|
|
|
48 |
# EpicDB Tables
|
|
|
49 |
T.backend_queue = Table('backend_queue', M.epic_meta, autoload=True)
|
|
|
50 |
T.object_metadata = Table('object_metadata', M.epic_meta, autoload=True)
|
|
|
51 |
T.feature_optin = Table('feature_optin', M.epic_meta, autoload=True)
|
|
|
52 |
T.feature_grouping = Table('feature_grouping', M.epic_meta, autoload=True)
|
|
|
53 |
T.sys_type_description = Table('sys_type_description', M.epic_meta, autoload=True)
|
|
|
54 |
|
22 |
|
55 |
def __call__(self, environ, start_response):
|
23 |
def __call__(self, environ, start_response):
|
56 |
request = Request(environ)
|
24 |
request = Request(environ)
|
57 |
try:
|
25 |
try:
|
58 |
self.handle(request)
|
26 |
self.handle(request)
|
|
... |
|
... |
61 |
resp = request.get_response(self.app)
|
29 |
resp = request.get_response(self.app)
|
62 |
return resp(environ, start_response)
|
30 |
return resp(environ, start_response)
|
63 |
|
31 |
|
64 |
def handle(self, request):
|
32 |
def handle(self, request):
|
65 |
request.environ.update(self.environ_values)
|
33 |
request.environ.update(self.environ_values)
|
|
|
34 |
|
|
|
35 |
def configure_databases(config):
|
|
|
36 |
M.site_meta.bind = engine_from_config(h.config_with_prefix(config, 'site_db.'))
|
|
|
37 |
M.mail_meta.bind = engine_from_config(h.config_with_prefix(config, 'mail_db.'))
|
|
|
38 |
M.task_meta.bind = engine_from_config(h.config_with_prefix(config, 'task_db.'))
|
|
|
39 |
M.epic_meta.bind = engine_from_config(h.config_with_prefix(config, 'epic_db.'))
|
|
|
40 |
# Configure SFX Database Tables
|
|
|
41 |
T = M.tables
|
|
|
42 |
# Alexandria Tables
|
|
|
43 |
T.mail_group_list = Table('mail_group_list', M.site_meta, autoload=True)
|
|
|
44 |
T.groups = Table(
|
|
|
45 |
'groups', M.site_meta, autoload=True,
|
|
|
46 |
include_columns=['group_id', 'group_name', 'status'])
|
|
|
47 |
T.mllist_subscriber = Table('mllist_subscriber', M.site_meta, autoload=True)
|
|
|
48 |
T.prweb_vhost = Table('prweb_vhost', M.site_meta, autoload=True)
|
|
|
49 |
T._mysql_auth = t = Table(
|
|
|
50 |
'mysql_auth', M.site_meta, autoload=True,
|
|
|
51 |
)
|
|
|
52 |
T.mysql_auth = select([
|
|
|
53 |
t,
|
|
|
54 |
func.which_user(t.c.modified_by_uid).label('modified_user')]).alias('msql_auth_user')
|
|
|
55 |
T.trove_cat = Table('trove_cat', M.site_meta, autoload=True)
|
|
|
56 |
# MailDB tables
|
|
|
57 |
T.lists = Table('lists', M.mail_meta, autoload=True)
|
|
|
58 |
# TaskDB Tables
|
|
|
59 |
T.ml_password_change = Table(
|
|
|
60 |
'ml_password_change', M.task_meta, autoload=True)
|
|
|
61 |
# EpicDB Tables
|
|
|
62 |
T.backend_queue = Table('backend_queue', M.epic_meta, autoload=True)
|
|
|
63 |
T.object_metadata = Table('object_metadata', M.epic_meta, autoload=True)
|
|
|
64 |
T.feature_optin = Table('feature_optin', M.epic_meta, autoload=True)
|
|
|
65 |
T.feature_grouping = Table('feature_grouping', M.epic_meta, autoload=True)
|
|
|
66 |
T.sys_type_description = Table('sys_type_description', M.epic_meta, autoload=True)
|
66 |
|
67 |
|
67 |
def engine_from_config(config):
|
68 |
def engine_from_config(config):
|
68 |
sa_scheme = config['scheme']
|
69 |
sa_scheme = config['scheme']
|
69 |
sa_user = config['username']
|
70 |
sa_user = config['username']
|
70 |
sa_password = config['password']
|
71 |
sa_password = config['password']
|