gws.base.action.manager¶
Action manager and helpers for CLI commands.
Source code: gws.base.action.manager
Module Contents¶
- gws.base.action.manager.get_action_for_cli(root: gws.Root, action_name: str, project_uid: str | None = None) gws.Action | None¶
Find an action for a CLI command, as the system user.
With a project uid, the action is searched in that project first. If it is not found there, or no project uid is given, it is searched among the application actions and then in all projects in turn. Errors are logged, not raised.
- Parameters:
root – The configuration root.
action_name – Action type, for example
alkis.project_uid – Optional project uid.
- Returns:
The action object, or
Noneif the project or the action is not found.
- class gws.base.action.manager.Object¶
Bases:
gws.ActionManagerAction manager.
- actions_for_project(project, user)¶
Get the actions a user can use in a project.
Includes the project actions and the application actions, one action per type. A project action takes precedence over an application action of the same type.
- Parameters:
project – The project.
user – The user.
- Returns:
A list of actions.
- find_action(project, ext_type, user)¶
Find an action by its type.
Searches the project actions first, if a project is given, then the application actions.
- Parameters:
project – The project, or
Noneto search the application actions only.ext_type – Action type, for example
map.user – The user who wants to use the action.
- Returns:
The action object, or
Noneif not found.- Raises:
ForbiddenError – If the action is found but the user may not use it.
- prepare_action(command_category, command_name, params, path, user, read_options=None)¶
Prepare a command call.
Parses the parameters into the command’s request type, finds the action that owns the command (in the requested project, then in the application) and checks the user’s access.
- Parameters:
command_category – Command category.
command_name – Command name, for example
mapDescribeLayer.params – Raw request parameters.
path – Request path; for
rawcommands, the project uid can be given as a/projectUid/<uid>segment.user – The user who runs the command.
read_options – Options for the spec reader.
- Returns:
A tuple of the bound command method and the parsed request object.
- Raises:
NotFoundError – If the command, the project or the action is not found.
BadRequestError – If the parameters cannot be parsed.
ForbiddenError – If the user may not use the project or the action.
- gws.base.action.manager.parse_cli_request(root: gws.Root, command_category: gws.CommandCategory, command_name: str, params: dict, read_options=None)¶
Parse command parameters and return a command handler on a new action object.
The action class is instantiated directly, it is not a configured tree node.
- Parameters:
root – The configuration root.
command_category – Command category.
command_name – Command name.
params – Raw command parameters.
read_options – Options for the spec reader.
- Returns:
A tuple of the bound command method and the parsed request object.
- Raises:
gws.NotFoundError – If the command is not found.
gws.BadRequestError – If the parameters cannot be parsed.