summaryrefslogtreecommitdiffstats
path: root/authentic2_idp_cas/app_settings.py
blob: 4560fd4fc4be7405b1234e36504384c59f578f1b (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
from django.utils.importlib import import_module

class AppSettings(object):

    def __init__(self, prefix):
        self.prefix = prefix

    @property
    def PROVIDER(self):
        cas_provider = self._setting('CAS_PROVIDER', 'authentic2_idp_cas.views.Authentic2CasProvider')
        module, cls = cas_provider.rsplit('.', 1)
        module = import_module(module)
        return getattr(module, cls)

    @property
    def TICKET_EXPIRATION(self):
        return self._setting('TICKET_EXPIRATION', 240)



    def _setting(self, name, dflt):
        from django.conf import settings
        return getattr(settings, self.prefix + name, dflt)



# Ugly? Guido recommends this himself ...
# http://mail.python.org/pipermail/python-ideas/2012-May/014969.html
import sys
app_settings = AppSettings('A2_IDP_CAS_')
app_settings.__name__ = __name__
sys.modules[__name__] = app_settings