From 6cea0592c2d7522b7e6501ebe52368618f92d58c Mon Sep 17 00:00:00 2001 From: hernani Date: Mon, 14 Mar 2011 18:09:41 +0000 Subject: [PATCH] Fixes bug in openid auth consumer, and problem with modules template loader. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@836 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/modules/__init__.py | 16 +++++++++----- forum/modules/template_loader.py | 2 +- forum_modules/openidauth/consumer.py | 32 +++++++++++++++------------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/forum/modules/__init__.py b/forum/modules/__init__.py index 976d9eb..f8e0fd1 100644 --- a/forum/modules/__init__.py +++ b/forum/modules/__init__.py @@ -2,23 +2,29 @@ import os import types import logging +from forum.utils.mixed import Proxy + MODULES_PACKAGE = 'forum_modules' -MODULES_FOLDER = None MODULE_LIST = [] def init_modules_engine(site_src_root, disabled_modules): - MODULES_FOLDER = os.path.join(site_src_root, MODULES_PACKAGE) + modules_folder = os.path.join(site_src_root, MODULES_PACKAGE) MODULE_LIST.extend(filter(lambda m: getattr(m, 'CAN_USE', True), [ __import__('forum_modules.%s' % f, globals(), locals(), ['forum_modules']) - for f in os.listdir(MODULES_FOLDER) - if os.path.isdir(os.path.join(MODULES_FOLDER, f)) and - os.path.exists(os.path.join(MODULES_FOLDER, "%s/__init__.py" % f)) and + for f in os.listdir(modules_folder) + if os.path.isdir(os.path.join(modules_folder, f)) and + os.path.exists(os.path.join(modules_folder, "%s/__init__.py" % f)) and not f in disabled_modules ])) + get_modules_folder.value = modules_folder + +def get_modules_folder(): + return get_modules_folder.value + def get_modules_script(script_name): all = [] diff --git a/forum/modules/template_loader.py b/forum/modules/template_loader.py index 61cb44e..d0e57ac 100644 --- a/forum/modules/template_loader.py +++ b/forum/modules/template_loader.py @@ -22,7 +22,7 @@ class ModulesTemplateLoader(BaseTemplateLoader): if name.startswith(MODULES_TEMPLATE_PREFIX): match = self.modules_re.search(name) - file_name = os.path.join(modules.MODULES_FOLDER, match.group(1), MODULES_TEMPLATE_FOLDER, match.group(2)) + file_name = os.path.join(modules.get_modules_folder(), match.group(1), MODULES_TEMPLATE_FOLDER, match.group(2)) if os.path.exists(file_name): template = Template(file_name) diff --git a/forum_modules/openidauth/consumer.py b/forum_modules/openidauth/consumer.py index 4c3818c..9b5d6e7 100644 --- a/forum_modules/openidauth/consumer.py +++ b/forum_modules/openidauth/consumer.py @@ -18,7 +18,7 @@ from store import OsqaOpenIDStore class OpenIdAbstractAuthConsumer(AuthenticationConsumer): dataype2ax_schema = { - #'username': 'http://axschema.org/namePerson/friendly', + 'username': 'http://axschema.org/namePerson/friendly', 'email': 'http://axschema.org/contact/email', #'web': 'http://axschema.org/contact/web/default', #'firstname': 'http://axschema.org/namePerson/first', @@ -112,30 +112,32 @@ class OpenIdAbstractAuthConsumer(AuthenticationConsumer): if sreg_attrs: sreg_response = SRegResponse.fromSuccessResponse(openid_response) - all_attrs = {} - [all_attrs.update(d) for k,d in sreg_attrs.items() if k != "policy_url"] + if sreg_response: + all_attrs = {} + [all_attrs.update(d) for k,d in sreg_attrs.items() if k != "policy_url"] - for attr_name, local_name in all_attrs.items(): - if attr_name in sreg_response: - consumer_data[local_name] = sreg_response[attr_name] + for attr_name, local_name in all_attrs.items(): + if attr_name in sreg_response: + consumer_data[local_name] = sreg_response[attr_name] ax_schema = getattr(self, 'dataype2ax_schema', False) if ax_schema: ax = AXFetchResponse.fromSuccessResponse(openid_response) - axargs = ax.getExtensionArgs() + if ax: + axargs = ax.getExtensionArgs() - ax_schema2data_type = dict([(s, t) for t, s in ax_schema.items()]) + ax_schema2data_type = dict([(s, t) for t, s in ax_schema.items()]) - available_types = dict([ - (ax_schema2data_type[s], re.sub('^type\.', '', n)) - for n, s in axargs.items() if s in ax_schema2data_type - ]) + available_types = dict([ + (ax_schema2data_type[s], re.sub('^type\.', '', n)) + for n, s in axargs.items() if s in ax_schema2data_type + ]) - for t, s in available_types.items(): - if not t in consumer_data: - consumer_data[t] = axargs["value.%s.1" % s] + for t, s in available_types.items(): + if not t in consumer_data: + consumer_data[t] = axargs["value.%s.1" % s] request.session['auth_consumer_data'] = consumer_data -- 2.45.1