Coverage for gws-app/gws/plugin/gbd_geoservices/finder.py: 0%
21 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"""The ``gbd_geoservices`` finder."""
3import os
5import gws
6import gws.base.search
7import gws.config.util
10_DEFAULT_TEMPLATES = [
11 gws.Config(
12 subject='feature.title',
13 type='html',
14 path=os.path.dirname(__file__) + '/templates/feature_title.cx.html',
15 ),
16 gws.Config(
17 subject='feature.teaser',
18 type='html',
19 path=os.path.dirname(__file__) + '/templates/feature_teaser.cx.html',
20 ),
21 gws.Config(
22 subject='feature.description',
23 type='html',
24 path=os.path.dirname(__file__) + '/templates/feature_description.cx.html',
25 ),
26]
29@gws.ext.config.finder('gbd_geoservices')
30class Config(gws.base.search.finder.Config):
31 """Keyword and location search via the GBD Geoservices service."""
33 apiKey: str
34 """API key for GBD Geoservices."""
37@gws.ext.object.finder('gbd_geoservices')
38class Object(gws.base.search.finder.Object):
39 """GBD Geoservices finder."""
41 supportsKeywordSearch = True
42 supportsGeometrySearch = True
44 def configure(self):
45 self.configure_models()
46 self.configure_templates()
48 def configure_templates(self):
49 return gws.config.util.configure_templates_for(self, extra=_DEFAULT_TEMPLATES)
51 def configure_models(self):
52 return gws.config.util.configure_models_for(self, with_default=True)
54 def create_model(self, cfg):
55 """Create a GBD Geoservices model with the API key of the finder.
57 Args:
58 cfg: Model configuration, or ``None`` for the default model.
60 Returns:
61 The model.
62 """
63 return self.create_child(
64 gws.ext.object.model,
65 cfg,
66 type=self.extType,
67 apiKey=self.cfg('apiKey'),
68 )