Skip to content

Commit

Permalink
Changed new_authz to also load the publisher specific auth from the l…
Browse files Browse the repository at this point in the history
…ogic.auth.publisher module
  • Loading branch information
rossjones committed Jan 18, 2012
1 parent c3b9df6 commit 30f99b6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
3 changes: 3 additions & 0 deletions ckan/logic/auth/publisher/create.py
@@ -0,0 +1,3 @@

# Make sure all functions defined here have publisher_ in front of their name
# so they are differentiated from the original auth functions.
Empty file.
Empty file.
Empty file.
31 changes: 20 additions & 11 deletions ckan/new_authz.py
Expand Up @@ -25,19 +25,28 @@ def _get_auth_function(action):
# Rather than writing them out in full will use __import__
# to load anything from ckan.auth that looks like it might
# be an authorisation function

# These lambdas are used to describe how we modify the name of the
modules = [
'ckan.logic.auth',
'ckan.logic.auth.publisher'
]

for auth_module_name in ['get', 'create', 'update','delete']:
module_path = 'ckan.logic.auth.'+auth_module_name
try:
module = __import__(module_path)
except ImportError,e:
log.debug('No auth module for action "%s"' % auth_module_name)
continue
for modroot in module_keys.keys():
module_path = modroot + '.' + auth_module_name
try:
module = __import__(module_path)
except ImportError,e:
log.debug('No auth module for action "%s"' % auth_module_name)
continue

for part in module_path.split('.')[1:]:
module = getattr(module, part)
for k, v in module.__dict__.items():
if not k.startswith('_'):
_auth_functions[k] = v
for part in module_path.split('.')[1:]:
module = getattr(module, part)

for key, v in module.__dict__.items():
if not key.startswith('_'):
_auth_functions[key] = v

# Then overwrite them with any specific ones in the plugins:
resolved_auth_function_plugins = {}
Expand Down

0 comments on commit 30f99b6

Please sign in to comment.