Commit | Line | Data |
---|---|---|
fc3dc255 | 1 | # GNU MediaGoblin -- federated, autonomous media hosting |
cf29e8a8 | 2 | # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS. |
fc3dc255 WKG |
3 | # |
4 | # This program is free software: you can redistribute it and/or modify | |
5 | # it under the terms of the GNU Affero General Public License as published by | |
6 | # the Free Software Foundation, either version 3 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU Affero General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
df9809c2 CAW |
16 | """ |
17 | In some places, we need to access the database, public_store, queue_store | |
18 | """ | |
19 | ||
b77eec65 CAW |
20 | import gettext |
21 | import pkg_resources | |
c80982c7 | 22 | import threading |
b77eec65 | 23 | |
218b8124 | 24 | |
df9809c2 CAW |
25 | ############################# |
26 | # General mediagoblin globals | |
27 | ############################# | |
28 | ||
bc142abc | 29 | # SQL database engine |
df9809c2 CAW |
30 | database = None |
31 | ||
0533f117 CAW |
32 | # beaker's cache manager |
33 | cache = None | |
34 | ||
df9809c2 CAW |
35 | # should be the same as the |
36 | public_store = None | |
37 | queue_store = None | |
38 | ||
49285baf E |
39 | # A WorkBenchManager |
40 | workbench_manager = None | |
41 | ||
c80982c7 JK |
42 | # A thread-local scope |
43 | thread_scope = threading.local() | |
44 | ||
7b9f9d1e SS |
45 | # gettext (this will be populated on demand with gettext.Translations) |
46 | thread_scope.translations = None | |
b77eec65 | 47 | |
218b8124 CAW |
48 | # app and global config objects |
49 | app_config = None | |
50 | global_config = None | |
51 | ||
52 | # The actual app object | |
53 | app = None | |
54 | ||
df9809c2 CAW |
55 | |
56 | def setup_globals(**kwargs): | |
68bf5b19 CAW |
57 | """ |
58 | Sets up a bunch of globals in this module. | |
59 | ||
60 | Takes the globals to setup as keyword arguments. If globals are | |
61 | specified that aren't set as variables above, then throw an error. | |
62 | """ | |
6e7ce8d1 | 63 | from mediagoblin import mg_globals |
df9809c2 CAW |
64 | |
65 | for key, value in kwargs.iteritems(): | |
49285baf E |
66 | if not hasattr(mg_globals, key): |
67 | raise AssertionError("Global %s not known" % key) | |
df9809c2 | 68 | setattr(mg_globals, key, value) |