Skip to content
Snippets Groups Projects
Commit 5882d8a8 authored by m431m's avatar m431m
Browse files

Workspace as services/{ws}.map by default

parent b8b950b5
No related branches found
No related tags found
No related merge requests found
...@@ -1035,7 +1035,7 @@ class MRA(object): ...@@ -1035,7 +1035,7 @@ class MRA(object):
# Services: # Services:
def get_service_path(self, *args): def get_service_path(self, *args):
root = self.config["storage"].get("services", self.get_path("available")) root = self.config["storage"].get("services", self.get_path("services"))
return self.get_path(root, *args) return self.get_path(root, *args)
def pub_service_path(self, path): def pub_service_path(self, path):
...@@ -1046,7 +1046,7 @@ class MRA(object): ...@@ -1046,7 +1046,7 @@ class MRA(object):
def get_service(self, name): def get_service(self, name):
path = self.get_service_path("%s.map" % name) path = self.get_service_path("%s.map" % name)
return Mapfile(path) return Mapfile(self.mk_path(path), needed=True)
# URL Helpers: # URL Helpers:
......
...@@ -117,6 +117,7 @@ class workspaces(object): ...@@ -117,6 +117,7 @@ class workspaces(object):
with webapp.mightConflict(): with webapp.mightConflict():
mra.create_workspace(ws_name).save() mra.create_workspace(ws_name).save()
# TODO Create associated service
webapp.Created("%s/workspaces/%s.%s" % (web.ctx.home, ws_name, format)) webapp.Created("%s/workspaces/%s.%s" % (web.ctx.home, ws_name, format))
...@@ -296,12 +297,19 @@ class featuretypes(object): ...@@ -296,12 +297,19 @@ class featuretypes(object):
ws.save() ws.save()
# Then creates the associated layer by default: # Then creates the associated layer by default:
# - in layers.map
model = ws.get_featuretypemodel(ds_name, data["name"]) model = ws.get_featuretypemodel(ds_name, data["name"])
mf = mra.get_available() mf = mra.get_available()
with webapp.mightConflict(): with webapp.mightConflict():
mf.create_layer(model, data["name"], True) mf.create_layer(model, data["name"], True)
mf.save() mf.save()
# - in {workspace}.map
wsmf = mra.get_service(ws_name)
with webapp.mightConflict():
wsmf.create_layer(model, data["name"], True)
wsmf.save()
webapp.Created("%s/workspaces/%s/datastores/%s/featuretypes/%s.%s" % ( webapp.Created("%s/workspaces/%s/datastores/%s/featuretypes/%s.%s" % (
web.ctx.home, ws.name, ds_name, data["name"], format)) web.ctx.home, ws.name, ds_name, data["name"], format))
...@@ -1296,6 +1304,42 @@ class OWSGlobalSettings(object): ...@@ -1296,6 +1304,42 @@ class OWSGlobalSettings(object):
mf.save() mf.save()
class OWSWorkspaceSettings(object):
"""Control settings of the main OWS service, i.e. the mapfile: layers.map
http://hostname/mra/services/[wms|wfs|wcs]/settings<lg>
"""
@HTTPCompatible()
def GET(self, ws_name, ows, format):
"""It returns the status of the OGC service."""
mf = mra.get_service(ws_name)
return {
ows: Entries({
"enabled": mf.get_metadata("%s_enable_request" % ows) == "*" and True or False,
"name": ows,
"schemaBaseURL": mf.get_metadata("ows_schemas_location", "http://schemas.opengis.net"),
}
)}
@HTTPCompatible()
def PUT(self, ws_name, ows, format):
"""To enable or disable OGC service..."""
mf = mra.get_service(ws_name)
data = get_data(name=ows, mandatory=["enabled"], authorized=["enabled"])
is_enabled = data.pop("enabled")
# TODO: That would be cool to be able to control each operation...
values = {True: "*", "True": "*", "true": "*",
False: "", "False": "", "false": ""}
if is_enabled not in values:
raise KeyError("\"%s\" is not valid" % is_enabled)
mf.set_metadata("%s_enable_request" % ows, values[is_enabled])
mf.save()
# Index: # Index:
urlmap(index, "") urlmap(index, "")
# About version: # About version:
...@@ -1333,6 +1377,7 @@ urlmap(layergroups, "layergroups") ...@@ -1333,6 +1377,7 @@ urlmap(layergroups, "layergroups")
urlmap(layergroup, "layergroups", ()) urlmap(layergroup, "layergroups", ())
# OGC Web Services: # OGC Web Services:
urlmap(OWSGlobalSettings, "services", "(wms|wfs|wcs)", "settings") urlmap(OWSGlobalSettings, "services", "(wms|wfs|wcs)", "settings")
urlmap(OWSWorkspaceSettings, "services", "workspaces", (), "(wms|wfs|wcs)", "settings")
urls = tuple(urlmap) urls = tuple(urlmap)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment