diff --git a/src/mapfile.py b/src/mapfile.py index b9665ddda868d8c0f9fbfca6dcfdbc63c1a10d00..05f725b01364d59ebb1fcaaf8e2e224e5ce6d619 100644 --- a/src/mapfile.py +++ b/src/mapfile.py @@ -726,11 +726,6 @@ class Mapfile(MetadataMixin): path = self.path self.ms.save(path) - def delete(self, path=None): - if path is None: - path = self.path - os.remove(path) - def rawtext(self): open(self.path, "r").read() diff --git a/src/server.py b/src/server.py index ab31b3887d67da0bfe6ae99754ec4cba330047f9..905a18a55c4d667619eb039889175138e21ba3b3 100755 --- a/src/server.py +++ b/src/server.py @@ -94,7 +94,7 @@ class mapfiles(object): map_name = data.pop("name") path = tools.mk_mapfile_path(map_name) - with webapp.mightConflict("Mapfile", mapfile=map_name): + with webapp.mightConflict(message="Mapfile '{exception}' already exists."): maptools.create_mapfile(path, map_name, data) webapp.Created("%s/maps/%s%s" % (web.ctx.home, map_name, (".%s" % format) if format else "")) @@ -121,21 +121,17 @@ class named_mapfile(object): data = get_data(name="mapfile", mandatory=["name"], authorized=["name", "title", "abstract"]) if map_name != data.pop("name"): raise webapp.Forbidden("Can't change the name of a mapfile.") - - with webapp.mightConflict("Mapfile", mapfile=map_name): - mf.update(data) + mf.update(data) mf.save() @HTTPCompatible() def DELETE(self, map_name, format): mf = get_mapfile(map_name) - path = tools.mk_mapfile_path(map_name) # TODO: We need to check if this mapfile is empty. - - with webapp.mightConflict("Mapfile", mapfile=map_name): - mf.delete() + with webapp.mightNotFound("Mapfile", mapfile=map_name): + os.remove(mf.path) class workspaces(object): diff --git a/tests/testScenario.py b/tests/testScenario.py index 98a3a54f0fdd862e16fb54fddc2a74c085be4d6f..ae60def3ca169118c989347a9cd1441a501bf63e 100644 --- a/tests/testScenario.py +++ b/tests/testScenario.py @@ -365,8 +365,9 @@ def test_scenario(): map_name = "tests" # Clean the test file, now we are sure it is empty. - APIRequest("PUT", target + "/tests/" + map_name) - + # APIRequest("PUT", target + "/tests/" + map_name) + APIRequest("DELETE", target + "/maps/" + map_name) + APIRequest("POST", target + "/maps", {"mapfile":{"name":map_name}}) # _test_workspaces(target, map_name) # _test_styles(target, map_name)