Coverage for gws-app/gws/base/storage/__init__.py: 100%
2 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Storage for data saved by users.
3Some client tools let users save their work under a name and load it later, for
4example annotations or dimensions. This package provides the server side for that.
6Submodules:
8- ``manager``: the storage manager (``gws.StorageManager``), configured in the
9 ``storage`` section of the application. It holds the storage providers
10 (``gws.StorageProvider``), which store named entries per category. Providers
11 are plugins, for example ``sqlite``. They are created as shared objects; a
12 provider with the same uid as an existing one replaces it.
13- ``core``: the storage object, a node that an action creates for its client
14 tool. It binds one provider and one category, checks the user's permissions
15 and handles the storage requests (``list``, ``read``, ``write``, ``delete``) of
16 the client. The ``Request``, ``Response`` and ``Props`` types are used by the
17 actions to define their storage command.
19Access to the entries is controlled by the ``access`` of the storage object:
20``read`` allows to list and read entries, ``write`` to overwrite existing ones,
21``create`` to add new ones and ``delete`` to delete them. Without a ``providerUid``
22the first configured provider is used.
24Example::
26 {
27 storage {
28 providers [
29 { type "sqlite" }
30 ]
31 }
32 actions [
33 {
34 type "dimension"
35 storage { access "allow all" }
36 }
37 ]
38 }
40Example::
42 class Object(gws.base.action.Object):
43 def configure(self):
44 self.storage = self.create_child_if_configured(
45 gws.base.storage.Object, self.cfg('storage'), categoryName='MyTool')
47 @gws.ext.command.api('myToolStorage')
48 def handle_storage(self, req, p: gws.base.storage.Request) -> gws.base.storage.Response:
49 return self.storage.handle_request(req, p)
50"""
52from .core import Request, Response, Config, Props, Object
53from . import manager