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

1 statements  

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

1"""Application object. 

2 

3The application is the single top-level node of the configuration tree, created 

4from the root configuration. It creates the managers (server, auth, database, 

5web, actions, search, models, templates, printers, jobs and others), the global 

6objects (actions, finders, models, templates, printers, exporters, OWS services, 

7helpers), the default client and finally the projects. Other objects reach these 

8through ``root.app``. 

9 

10Submodules: 

11 

12- ``core``: the application ``Object`` and its root ``Config``. 

13- ``middleware``: the middleware manager, which orders objects that process each 

14 web request (for example ``db`` and ``auth``) by their dependencies. 

15- ``templates``: the built-in templates for the home, error, project and feature 

16 pages, added to the application templates by default. 

17 

18Configuration order matters: databases and helpers are configured first, then 

19storage and auth, then actions, the web site, search, models, templates, 

20exporters, jobs, printers, OWS services and the client; projects come last, 

21so they can use all global objects. 

22 

23Built-in templates for the default subjects and a default printer are added 

24after the configured ones, so configured templates take precedence. The 

25template option ``withLogin`` defaults to whether an ``auth`` action is configured. 

26 

27The middleware manager returns the objects in dependency order, sorted on first 

28use after a registration. A cyclic or unknown dependency raises ``gws.Error``. 

29 

30Helpers are configured with ``helpers`` or created on demand by ``app.helper``. 

31On activation, the application sets the log level and makes the server monitor 

32watch the configuration files and project directories. 

33 

34Example:: 

35 

36 { 

37 title "My application" 

38 locales [ "de_DE" "en_US" ] 

39 actions [ 

40 { type web } 

41 { type map } 

42 ] 

43 projectDirs [ "/data/projects" ] 

44 } 

45 

46Example:: 

47 

48 project = root.app.project('project_1') 

49 helper = root.app.helper('upload') 

50""" 

51 

52from .core import Config, Object