From e4f38380deab1ec8711ffd8b0fe5b69091782752 Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Wed, 28 Nov 2012 15:17:59 +0100 Subject: [PATCH 1/3] Fix a crash in mock_publisher_auth mock_publisher_auth uses `log` but doesn't initialise it. Import logging and initialise log. --- ckan/tests/mock_publisher_auth.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ckan/tests/mock_publisher_auth.py b/ckan/tests/mock_publisher_auth.py index 749588a4fd9..01a292424ea 100644 --- a/ckan/tests/mock_publisher_auth.py +++ b/ckan/tests/mock_publisher_auth.py @@ -1,5 +1,8 @@ from ckan.new_authz import is_authorized from ckan.logic import NotAuthorized +import logging + +log = logging.getLogger("mock_publisher_auth") class MockPublisherAuth(object): """ From 6aad4b8aa4549d613769ac57896773532287172f Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Wed, 28 Nov 2012 15:19:56 +0100 Subject: [PATCH 2/3] Delete an unused import --- ckan/tests/mock_publisher_auth.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ckan/tests/mock_publisher_auth.py b/ckan/tests/mock_publisher_auth.py index 01a292424ea..57e136ee23a 100644 --- a/ckan/tests/mock_publisher_auth.py +++ b/ckan/tests/mock_publisher_auth.py @@ -1,4 +1,3 @@ -from ckan.new_authz import is_authorized from ckan.logic import NotAuthorized import logging From 53013843af361b7310a6418b3609c2ff1fc0378e Mon Sep 17 00:00:00 2001 From: Sean Hammond Date: Wed, 28 Nov 2012 15:21:02 +0100 Subject: [PATCH 3/3] PEP8 fixes --- ckan/tests/mock_publisher_auth.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ckan/tests/mock_publisher_auth.py b/ckan/tests/mock_publisher_auth.py index 57e136ee23a..475666a21eb 100644 --- a/ckan/tests/mock_publisher_auth.py +++ b/ckan/tests/mock_publisher_auth.py @@ -3,21 +3,22 @@ log = logging.getLogger("mock_publisher_auth") + class MockPublisherAuth(object): """ MockPublisherAuth """ - + def __init__(self): self.functions = {} self._load() def _load(self): - for auth_module_name in ['get', 'create', 'update','delete']: + for auth_module_name in ['get', 'create', 'update', 'delete']: module_path = 'ckan.logic.auth.publisher.%s' % (auth_module_name,) try: module = __import__(module_path) - except ImportError,e: + except ImportError: log.debug('No auth module for action "%s"' % auth_module_name) continue @@ -27,10 +28,9 @@ def _load(self): for key, v in module.__dict__.items(): if not key.startswith('_'): self.functions[key] = v - - - def check_access(self,action, context, data_dict): + + def check_access(self, action, context, data_dict): logic_authorization = self.functions[action](context, data_dict) if not logic_authorization['success']: - msg = logic_authorization.get('msg','') + msg = logic_authorization.get('msg', '') raise NotAuthorized(msg)