Coverage for gws-app/gws/plugin/annotate_tool/action.py: 0%
27 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 23:09 +0200
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-16 23:09 +0200
1"""Annotate action."""
3from typing import Optional
5import gws
6import gws.base.action
7import gws.base.web
8import gws.base.storage
10gws.ext.new.action('annotate')
13class Config(gws.base.action.Config):
14 """Annotate action configuration."""
16 storage: Optional[gws.base.storage.Config]
17 """Storage configuration."""
18 labels: Optional[dict]
19 """Default label templates."""
22class Props(gws.base.action.Props):
23 storage: gws.base.storage.Props
24 labels: dict
27class Object(gws.base.action.Object):
28 storage: Optional[gws.base.storage.Object]
29 labels: Optional[dict]
31 def configure(self):
32 self.storage = self.create_child_if_configured(
33 gws.base.storage.Object,
34 self.cfg('storage'),
35 categoryName='Annotate',
36 )
37 self.labels = self.cfg('labels')
39 def props(self, user):
40 return gws.u.merge(
41 super().props(user),
42 storage=self.storage,
43 labels=self.labels,
44 )
46 @gws.ext.command.api('annotateStorage')
47 def handle_storage(self, req: gws.WebRequester, p: gws.base.storage.Request) -> gws.base.storage.Response:
48 if not self.storage:
49 raise gws.NotFoundError('no storage configured')
50 return self.storage.handle_request(req, p)