File: utils.py

package info (click to toggle)
python-django-casclient 1.5.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 212 kB
  • sloc: python: 756; makefile: 160
file content (26 lines) | stat: -rw-r--r-- 650 bytes parent folder | download | duplicates (9)
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
import logging

from django.conf import settings


logger = logging.getLogger(__name__)


def cas_response_callbacks(tree):
    callbacks = []
    callbacks.extend(settings.CAS_RESPONSE_CALLBACKS)

    for path in callbacks:
        i = path.rfind('.')
        module, callback = path[:i], path[i+1:]
        try:
            mod = __import__(module, fromlist=[''])
        except ImportError as e:
            logger.error("Import Error: %s" % e)
            raise e
        try:
            func = getattr(mod, callback)
        except AttributeError as e:
            logger.error("Attribute Error: %s" % e)
            raise e
        func(tree)