Coverage for gws-app/gws/plugin/annotate_tool/action.py: 0%
27 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +0200
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-17 01:37 +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 storage: Optional[gws.base.storage.Config]
15 """storage configuration"""
16 labels: Optional[dict]
17 """default label templates"""
20class Props(gws.base.action.Props):
21 storage: gws.base.storage.Props
22 labels: dict
25class Object(gws.base.action.Object):
26 storage: Optional[gws.base.storage.Object]
27 labels: Optional[dict]
29 def configure(self):
30 self.storage = self.create_child_if_configured(
31 gws.base.storage.Object, self.cfg('storage'), categoryName='Annotate')
32 self.labels = self.cfg('labels')
34 def props(self, user):
35 return gws.u.merge(
36 super().props(user),
37 storage=self.storage,
38 labels=self.labels,
39 )
41 @gws.ext.command.api('annotateStorage')
42 def handle_storage(self, req: gws.WebRequester, p: gws.base.storage.Request) -> gws.base.storage.Response:
43 if not self.storage:
44 raise gws.NotFoundError('no storage configured')
45 return self.storage.handle_request(req, p)