X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/a9eef437702d5df7a2f97010e6798c689371808c..162b4fd442c169a61d2f5b2b3bd613546c8472da:/forum/authentication/__init__.py?ds=sidebyside diff --git a/forum/authentication/__init__.py b/forum/authentication/__init__.py old mode 100755 new mode 100644 index e83ba87..8dbf825 --- a/forum/authentication/__init__.py +++ b/forum/authentication/__init__.py @@ -1,27 +1,33 @@ -import re -from forum.modules import get_modules_script_classes -from forum.authentication.base import AuthenticationConsumer, ConsumerTemplateContext - -class ConsumerAndContext(): - def __init__(self, id, consumer, context): - self.id = id - self.consumer = consumer() - - context.id = id - self.context = context - -consumers = dict([ - (re.sub('AuthConsumer$', '', name).lower(), cls) for name, cls - in get_modules_script_classes('authentication', AuthenticationConsumer).items() - if not re.search('AbstractAuthConsumer$', name) - ]) - -contexts = dict([ - (re.sub('AuthContext$', '', name).lower(), cls) for name, cls - in get_modules_script_classes('authentication', ConsumerTemplateContext).items() - ]) - -AUTH_PROVIDERS = dict([ - (name, ConsumerAndContext(name, consumers[name], contexts[name])) for name in consumers.keys() - if name in contexts - ]) \ No newline at end of file +import re +import django.dispatch +from forum.modules import get_modules_script_classes +from forum.authentication.base import AuthenticationConsumer, ConsumerTemplateContext + +class ConsumerAndContext: + def __init__(self, id, consumer, context): + self.id = id + self._consumer = consumer + + context.id = id + self.context = context + + @property + def consumer(self): + return self._consumer() + +consumers = dict([ + (re.sub('AuthConsumer$', '', name).lower(), cls) for name, cls + in get_modules_script_classes('authentication', AuthenticationConsumer).items() + if not re.search('AbstractAuthConsumer$', name) + ]) + +contexts = dict([ + (re.sub('AuthContext$', '', name).lower(), cls) for name, cls + in get_modules_script_classes('authentication', ConsumerTemplateContext).items() + ]) + +AUTH_PROVIDERS = dict([ + (name, ConsumerAndContext(name, consumers[name], contexts[name])) for name in consumers.keys() + if name in contexts + ]) +