3d0ed61d33a5c58ee6eb66c79f679279bfbeb4fe
[mediagoblin.git] / mediagoblin / mg_globals.py
1 """
2 In some places, we need to access the database, public_store, queue_store
3 """
4
5 import gettext
6 import pkg_resources
7
8 #############################
9 # General mediagoblin globals
10 #############################
11
12 # mongokit.Connection
13 db_connection = None
14
15 # mongokit.Connection
16 database = None
17
18 # should be the same as the
19 public_store = None
20 queue_store = None
21
22 # Dump mail to stdout instead of sending it:
23 email_debug_mode = False
24
25 # Address for sending out mails
26 email_sender_address = None
27
28 # A WorkBenchManager
29 workbench_manager = None
30
31 # gettext
32 translations = gettext.find(
33 'mediagoblin',
34 pkg_resources.resource_filename(
35 'mediagoblin', 'translations'), ['en'])
36
37
38 def setup_globals(**kwargs):
39 from mediagoblin import mg_globals
40
41 for key, value in kwargs.iteritems():
42 if not hasattr(mg_globals, key):
43 raise AssertionError("Global %s not known" % key)
44 setattr(mg_globals, key, value)