Expect 404 in unit tests, if we now use 404.
[mediagoblin.git] / mediagoblin / mg_globals.py
... / ...
CommitLineData
1# GNU MediaGoblin -- federated, autonomous media hosting
2# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
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/>.
16"""
17In some places, we need to access the database, public_store, queue_store
18"""
19
20import gettext
21import pkg_resources
22
23
24#############################
25# General mediagoblin globals
26#############################
27
28# mongokit.Connection
29db_connection = None
30
31# mongokit.Connection
32database = None
33
34# beaker's cache manager
35cache = None
36
37# should be the same as the
38public_store = None
39queue_store = None
40
41# A WorkBenchManager
42workbench_manager = None
43
44# gettext
45translations = gettext.find(
46 'mediagoblin',
47 pkg_resources.resource_filename(
48 'mediagoblin', 'translations'), ['en'])
49
50# app and global config objects
51app_config = None
52global_config = None
53
54# The actual app object
55app = None
56
57
58def setup_globals(**kwargs):
59 """
60 Sets up a bunch of globals in this module.
61
62 Takes the globals to setup as keyword arguments. If globals are
63 specified that aren't set as variables above, then throw an error.
64 """
65 from mediagoblin import mg_globals
66
67 for key, value in kwargs.iteritems():
68 if not hasattr(mg_globals, key):
69 raise AssertionError("Global %s not known" % key)
70 setattr(mg_globals, key, value)