2 Basic utilities for applications.
6 from django.conf import settings
9 class AppSettings(object):
10 """Allows specyfying custom settings for an app, with default values.
12 Just subclass, set some properties and instantiate with a prefix.
13 Getting a SETTING from an instance will check for prefix_SETTING
14 in project settings if set, else take the default. The value will be
15 then filtered through _more_SETTING method, if there is one.
18 def __init__(self, prefix):
21 def __getattribute__(self, name):
22 if name.startswith('_'):
23 return object.__getattribute__(self, name)
24 value = getattr(settings,
25 "%s_%s" % (self._prefix, name),
26 object.__getattribute__(self, name))
27 more = "_more_%s" % name
28 if hasattr(self, more):
29 value = getattr(self, more)(value)