Commit | Line | Data |
---|---|---|
fc3dc255 WKG |
1 | # GNU MediaGoblin -- federated, autonomous media hosting |
2 | # Copyright (C) 2011 Free Software Foundation, Inc | |
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 | |
22 | ||
218b8124 | 23 | |
df9809c2 CAW |
24 | ############################# |
25 | # General mediagoblin globals | |
26 | ############################# | |
27 | ||
28 | # mongokit.Connection | |
29 | db_connection = None | |
30 | ||
31 | # mongokit.Connection | |
32 | database = None | |
33 | ||
34 | # should be the same as the | |
35 | public_store = None | |
36 | queue_store = None | |
37 | ||
49285baf E |
38 | # A WorkBenchManager |
39 | workbench_manager = None | |
40 | ||
b77eec65 CAW |
41 | # gettext |
42 | translations = gettext.find( | |
43 | 'mediagoblin', | |
44 | pkg_resources.resource_filename( | |
45 | 'mediagoblin', 'translations'), ['en']) | |
46 | ||
218b8124 CAW |
47 | # app and global config objects |
48 | app_config = None | |
49 | global_config = None | |
50 | ||
51 | # The actual app object | |
52 | app = None | |
53 | ||
df9809c2 CAW |
54 | |
55 | def setup_globals(**kwargs): | |
68bf5b19 CAW |
56 | """ |
57 | Sets up a bunch of globals in this module. | |
58 | ||
59 | Takes the globals to setup as keyword arguments. If globals are | |
60 | specified that aren't set as variables above, then throw an error. | |
61 | """ | |
6e7ce8d1 | 62 | from mediagoblin import mg_globals |
df9809c2 CAW |
63 | |
64 | for key, value in kwargs.iteritems(): | |
49285baf E |
65 | if not hasattr(mg_globals, key): |
66 | raise AssertionError("Global %s not known" % key) | |
df9809c2 | 67 | setattr(mg_globals, key, value) |