"""OWS server."""
import gws
import gws.common.action
import gws.common.ows.service
import gws.web.error
import gws.types as t
[docs]class Config(t.WithTypeAndAccess):
"""OWS server action"""
services: t.Optional[t.List[t.ext.ows.service.Config]] #: services configuration
[docs]class Object(gws.common.action.Object):
[docs] def http_service(self, req: t.IRequest, _) -> t.HttpResponse:
service = self._find_service(req)
if not service:
gws.log.debug('service not found')
raise gws.web.error.NotFound()
gws.log.debug(f'found service={service.uid}')
if not req.user.can_use(service):
return service.error_response(gws.web.error.Forbidden())
try:
return service.handle(req)
except gws.web.error.HTTPException as err:
return service.error_response(err)
except:
gws.log.exception()
return service.error_response(gws.web.error.InternalServerError())
def _find_service(self, req):
uid = req.param('uid')
for service in self.services:
if service.uid == uid:
return service