Skip to content

Commit

Permalink
Merge branch 'master' of github.com:okfn/ckan into 1635-feature-email…
Browse files Browse the repository at this point in the history
…-notifications-for-activity-streams
  • Loading branch information
Sean Hammond committed Nov 28, 2012
2 parents 0cdb0d3 + 5301384 commit 48a5d1f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions ckan/tests/mock_publisher_auth.py
@@ -1,21 +1,24 @@
from ckan.new_authz import is_authorized
from ckan.logic import NotAuthorized
import logging

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

Expand All @@ -25,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)

0 comments on commit 48a5d1f

Please sign in to comment.