Created
October 16, 2010 22:12
-
-
Save matagus/630328 to your computer and use it in GitHub Desktop.
django sttings proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.utils.translation import ugettext_lazy as _ | |
from django.conf import settings as django_settings | |
class SettingsProxy(object): | |
def __init__(self, settings, defaults): | |
self.settings = settings | |
self.defaults = defaults | |
def __getattr__(self, attr): | |
try: | |
return getattr(self.settings, attr) | |
except AttributeError: | |
try: | |
return getattr(self.defaults, attr) | |
except AttributeError: | |
raise AttributeError, u'settings object has no attribute "%s"' % attr | |
class defaults(object): | |
FLAVOURS = (u'full', u'mobile',) | |
DEFAULT_MOBILE_FLAVOUR = u'mobile' | |
FLAVOURS_TEMPLATE_DIRS_PREFIX = u'' | |
FLAVOURS_GET_PARAMETER = u'flavour' | |
FLAVOURS_SESSION_KEY = u'flavour' | |
settings = SettingsProxy(django_settings, defaults) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment