def get_action(action):
 if _actions:
  if (action not in _actions):
   raise KeyError(("Action '%s' not found" % action))
  return _actions.get(action)
 for action_module_name in ['get', 'create', 'update', 'delete', 'patch']:
  module_path = ('ckan.logic.action.' + action_module_name)
  module = __import__(module_path)
  for part in module_path.split('.')[1:]:
   module = getattr(module, part)
  for (k, v) in module.__dict__.items():
   if (not k.startswith('_')):
    if (hasattr(v, '__call__') and ((v.__module__ == module_path) or hasattr(v, '__replaced'))):
     _actions[k] = v
     if ((action_module_name == 'get') and (not hasattr(v, 'side_effect_free'))):
      v.side_effect_free = True
 resolved_action_plugins = {}
 fetched_actions = {}
 for plugin in p.PluginImplementations(p.IActions):
  for (name, auth_function) in plugin.get_actions().items():
   if (name in resolved_action_plugins):
    raise NameConflict(('The action %r is already implemented in %r' % (name, resolved_action_plugins[name])))
   resolved_action_plugins[name] = plugin.name
   auth_function.auth_audit_exempt = True
   fetched_actions[name] = auth_function
 _actions.update(fetched_actions)
 for (action_name, _action) in _actions.items():
  def make_wrapped(_action, action_name):
   def wrapped(context=None, data_dict=None, **kw):
    if kw:
     log.critical(('%s was passed extra keywords %r' % (_action.__name__, kw)))
    context = _prepopulate_context(context)
    context.setdefault('__auth_audit', [])
    context['__auth_audit'].append((action_name, id(_action)))
    result = _action(context, data_dict, **kw)
    try:
     audit = context['__auth_audit'][(-1)]
     if ((audit[0] == action_name) and (audit[1] == id(_action))):
      if (action_name not in authz.auth_functions_list()):
       log.debug(('No auth function for %s' % action_name))
      elif (not getattr(_action, 'auth_audit_exempt', False)):
       raise Exception('Action function {0} did not call its auth function'.format(action_name))
      context['__auth_audit'].pop()
    except IndexError:
     pass
    return result
   return wrapped
  if hasattr(_action, '__replaced'):
   _actions[action_name] = _action.__replaced
   continue
  fn = make_wrapped(_action, action_name)
  fn.__doc__ = _action.__doc__
  if getattr(_action, 'side_effect_free', False):
   fn.side_effect_free = True
  _actions[action_name] = fn
 return _actions.get(action)

def get_action ( action ) : if _actions : if ( action not in _actions ) : raise KeyError ( ( "Action '%s' not found" % action ) ) return _actions . get ( action ) for action_module_name in [ 'get' , 'create' , 'update' , 'delete' , 'patch' ] : module_path = ( 'ckan.logic.action.' + action_module_name ) module = __import__ ( module_path ) for part in module_path . split ( '.' ) [ 1 : ] : module = getattr ( module , part ) for ( k , v ) in module . __dict__ . items ( ) : if ( not k . startswith ( '_' ) ) : if ( hasattr ( v , '__call__' ) and ( ( v . __module__ == module_path ) or hasattr ( v , '__replaced' ) ) ) : _actions [ k ] = v if ( ( action_module_name == 'get' ) and ( not hasattr ( v , 'side_effect_free' ) ) ) : v . side_effect_free = True resolved_action_plugins = { } fetched_actions = { } for plugin in p . PluginImplementations ( p . IActions ) : for ( name , auth_function ) in plugin . get_actions ( ) . items ( ) : if ( name in resolved_action_plugins ) : raise NameConflict ( ( 'The action %r is already implemented in %r' % ( name , resolved_action_plugins [ name ] ) ) ) resolved_action_plugins [ name ] = plugin . name auth_function . auth_audit_exempt = True fetched_actions [ name ] = auth_function _actions . update ( fetched_actions ) for ( action_name , _action ) in _actions . items ( ) : def make_wrapped ( _action , action_name ) : def wrapped ( context = None , data_dict = None , ** kw ) : if kw : log . critical ( ( '%s was passed extra keywords %r' % ( _action . __name__ , kw ) ) ) context = _prepopulate_context ( context ) context . setdefault ( '__auth_audit' , [ ] ) context [ '__auth_audit' ] . append ( ( action_name , id ( _action ) ) ) result = _action ( context , data_dict , ** kw ) try : audit = context [ '__auth_audit' ] [ ( - 1 ) ] if ( ( audit [ 0 ] == action_name ) and ( audit [ 1 ] == id ( _action ) ) ) : if ( action_name not in authz . auth_functions_list ( ) ) : log . debug ( ( 'No auth function for %s' % action_name ) ) elif ( not getattr ( _action , 'auth_audit_exempt' , False ) ) : raise Exception ( 'Action function {0} did not call its auth function' . format ( action_name ) ) context [ '__auth_audit' ] . pop ( ) except IndexError : pass return result return wrapped if hasattr ( _action , '__replaced' ) : _actions [ action_name ] = _action . __replaced continue fn = make_wrapped ( _action , action_name ) fn . __doc__ = _action . __doc__ if getattr ( _action , 'side_effect_free' , False ) : fn . side_effect_free = True _actions [ action_name ] = fn return _actions . get ( action )
calls an action function from a template .