zvoase (owner)

Fork Of

gist: 63878 by anonymous

Revisions

gist: 64043 Download_button fork
public
Public Clone URL: git://gist.github.com/64043.git
Embed All Files: show embed
settings/__init__.py #
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
import os
 
def import_all_from(module_name, globals_):
    # Calling it with the globals_ module provides a hook into the
    # module-level globals; otherwise we'd get the function's globals
    # (which might be different).
    module_split = module_name.split('.')
    while '__init__' in module_split:
        module_split.remove('__init__')
    while '__main__' in module_split:
        module_split.remove('__main__')
    module = __import__('.'.join(module_split), fromlist=module_split[:-1])
    for attr in dir(module):
        if not (attr.startswith('__') and attr.endswith('__')):
            globals_[attr] = getattr(module, attr)
 
SETTINGS_MODE = os.environ.get('DJANGO_SETTINGS_MODE', None)
 
import_all_from(__name__ + '.common', globals())
 
try:
    import_all_from(__name__ + '.modes', globals())
except ImportError:
    pass
 
if 'SETTINGS_MODES' in dir():
    for mode in SETTINGS_MODES:
        import_all_from(__name__ + '.' + mode.lower(), globals())
elif SETTINGS_MODE:
    import_all_from(__name__ + '.' + SETTINGS_MODE.lower(), globals())