aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/mg_globals.py
blob: 739f44eed512c512a731470e7a03788a7bc3c70c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
In some places, we need to access the database, public_store, queue_store
"""

import gettext
import pkg_resources


#############################
# General mediagoblin globals
#############################

# mongokit.Connection
db_connection = None

# mongokit.Connection
database = None

# should be the same as the 
public_store = None
queue_store = None

# Dump mail to stdout instead of sending it:
email_debug_mode = False

# Address for sending out mails
email_sender_address = None

# A WorkBenchManager
workbench_manager = None

# gettext
translations = gettext.find(
    'mediagoblin',
    pkg_resources.resource_filename(
    'mediagoblin', 'translations'), ['en'])

# app and global config objects
app_config = None
global_config = None

# The actual app object
app = None


def setup_globals(**kwargs):
    """
    Sets up a bunch of globals in this module.

    Takes the globals to setup as keyword arguments.  If globals are
    specified that aren't set as variables above, then throw an error.
    """
    from mediagoblin import mg_globals

    for key, value in kwargs.iteritems():
        if not hasattr(mg_globals, key):
            raise AssertionError("Global %s not known" % key)
        setattr(mg_globals, key, value)