Coverage for gws-app/gws/base/action/__init__.py: 100%

3 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Server actions. 

2 

3An action is a configurable object that groups server commands, for example 

4``map``, ``search`` or ``printer``. Actions are configured globally in the 

5application and per project. A command method of an action is marked with a 

6``gws.ext.command.*`` decorator (``api``, ``get``, ``post``, ``cli``, ``raw``) 

7and is invoked by the web server or the command line. 

8 

9Submodules: 

10 

11- ``core``: the ``Object`` base class of all actions, and the base ``Config`` and ``Props``. 

12- ``manager``: the action manager (``gws.ActionManager``), which locates actions 

13 and prepares command calls, plus helpers for CLI commands. 

14- ``cli``: the ``gws action`` CLI commands, which invoke or profile a web action 

15 from the command line. 

16 

17When a request comes in, the action manager looks up the command descriptor in 

18the specs, parses the request parameters into the command's request type, finds 

19the action in the requested project (falling back to the application-level 

20actions) and checks the user's access. Project actions take precedence over 

21application actions of the same type. An action the user may not use raises 

22``gws.ForbiddenError`` rather than being skipped. 

23 

24For ``raw`` commands, the request parameters are not parsed; only ``projectUid`` 

25(also taken from a ``/projectUid/<uid>`` path segment) and ``localeUid`` are read. 

26 

27Example:: 

28 

29 actions [ 

30 { type map } 

31 { type search access "allow all" } 

32 ] 

33 

34 projects [ 

35 { 

36 uid "project_1" 

37 actions [ 

38 { type edit } 

39 ] 

40 } 

41 ] 

42 

43Example:: 

44 

45 fn, request = root.app.actionMgr.prepare_action( 

46 gws.CommandCategory.api, 'mapDescribeLayer', params, '', user) 

47 response = fn(requester, request) 

48""" 

49 

50from . import manager 

51from .core import Config, Object, Props 

52from .manager import parse_cli_request, get_action_for_cli