Skip to content

Instantly share code, notes, and snippets.

@hartred
Last active January 24, 2018 09:32
Show Gist options
  • Save hartred/63325e78ac9dccf044ae61a6f48796ef to your computer and use it in GitHub Desktop.
Save hartred/63325e78ac9dccf044ae61a6f48796ef to your computer and use it in GitHub Desktop.
import importlib
import os
SETTINGS_MODULE = os.environ('SETTINGS_MODULE')
class Borg:
_shared_state = {}
def __init__(self):
self.__dict__ = self._shared_state
class Settings(Borg):
settings_module = None
def __init__(self):
super().__init__()
settings_module = importlib.import_module(SETTINGS_MODULE)
for setting in dir(settings_module):
if setting.isupper() and not getattr(self, setting):
setattr(self, setting, getattr(settings_module, setting))
def assert_settings_errors(self):
raise NotImplementedError
settings = Settings()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment