Starts the user (profile) endpoint and lays groundwork for inbox and feed endpoint
[larjonas-mediagoblin.git] / mediagoblin / mg_globals.py
blob26ed66fab87eedae3fcfb22210e9efb114457c65
1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
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.
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.
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 """
17 In some places, we need to access the database, public_store, queue_store
18 """
20 import gettext
21 import pkg_resources
22 import threading
25 #############################
26 # General mediagoblin globals
27 #############################
29 # SQL database engine
30 database = None
32 # should be the same as the
33 public_store = None
34 queue_store = None
36 # A WorkBenchManager
37 workbench_manager = None
39 # A thread-local scope
40 thread_scope = threading.local()
42 # gettext (this needs to default to English so it doesn't break
43 # in case we're running a script without the app like
44 # ./bin/gmg theme assetlink)
45 thread_scope.translations = gettext.translation(
46 'mediagoblin',
47 pkg_resources.resource_filename(
48 'mediagoblin', 'i18n'), ['en'], fallback=True)
50 # app and global config objects
51 app_config = None
52 global_config = None
54 # The actual app object
55 app = None
58 def setup_globals(**kwargs):
59 """
60 Sets up a bunch of globals in this module.
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
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)