Fix ascii media type for Python 3. Fix by 宋文武 (iyzsong)
[mediagoblin.git] / mediagoblin / mg_globals.py
CommitLineData
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"""
17In some places, we need to access the database, public_store, queue_store
18"""
19
b77eec65
CAW
20import gettext
21import pkg_resources
c80982c7 22import threading
b77eec65 23
386c9c7c 24import six
218b8124 25
df9809c2
CAW
26#############################
27# General mediagoblin globals
28#############################
29
bc142abc 30# SQL database engine
df9809c2
CAW
31database = None
32
33# should be the same as the
34public_store = None
35queue_store = None
36
49285baf
E
37# A WorkBenchManager
38workbench_manager = None
39
c80982c7
JK
40# A thread-local scope
41thread_scope = threading.local()
42
a808364e
CAW
43# gettext (this needs to default to English so it doesn't break
44# in case we're running a script without the app like
45# ./bin/gmg theme assetlink)
46thread_scope.translations = gettext.translation(
47 'mediagoblin',
48 pkg_resources.resource_filename(
49 'mediagoblin', 'i18n'), ['en'], fallback=True)
b77eec65 50
218b8124
CAW
51# app and global config objects
52app_config = None
53global_config = None
54
55# The actual app object
56app = None
57
df9809c2
CAW
58
59def setup_globals(**kwargs):
68bf5b19
CAW
60 """
61 Sets up a bunch of globals in this module.
62
63 Takes the globals to setup as keyword arguments. If globals are
64 specified that aren't set as variables above, then throw an error.
65 """
6e7ce8d1 66 from mediagoblin import mg_globals
df9809c2 67
386c9c7c 68 for key, value in six.iteritems(kwargs):
49285baf
E
69 if not hasattr(mg_globals, key):
70 raise AssertionError("Global %s not known" % key)
df9809c2 71 setattr(mg_globals, key, value)