Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
Mapserver REST API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miscellaneous
Mapserver REST API
Commits
39ce8222
Commit
39ce8222
authored
11 years ago
by
Wannes Rombouts
Browse files
Options
Downloads
Patches
Plain Diff
Added checks to not delete stuff that is beeing used.
parent
f1d999e0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/server.py
+24
-0
24 additions, 0 deletions
src/server.py
src/tools.py
+9
-1
9 additions, 1 deletion
src/tools.py
with
33 additions
and
1 deletion
src/server.py
+
24
−
0
View file @
39ce8222
...
...
@@ -188,6 +188,9 @@ class datastore(object):
def
DELETE
(
self
,
map_name
,
ws_name
,
ds_name
,
format
):
mf
,
ws
=
get_mapfile_workspace
(
map_name
,
ws_name
)
# We need to check if this datatore is empty.
assert_is_empty
(
ws
.
iter_featuretypes
(
ds_name
=
ds_name
),
"
datastore
"
,
ds_name
)
with
webapp
.
mightNotFound
(
"
dataStore
"
,
workspace
=
ws_name
):
ws
.
delete_datastore
(
ds_name
)
ws
.
save
()
...
...
@@ -292,6 +295,10 @@ class featuretype(object):
def
DELETE
(
self
,
map_name
,
ws_name
,
ds_name
,
ft_name
,
format
):
mf
,
ws
=
get_mapfile_workspace
(
map_name
,
ws_name
)
# We need to check if there are any layers using this.
assert_is_empty
(
mg
.
iter_layers
(
mra
=
{
"
name
"
:
ft_name
,
"
workspace
"
:
ws_name
,
"
storage
"
:
ds_name
,
"
type
"
:
"
featuretype
"
}),
"
featuretype
"
,
ft_name
)
with
webapp
.
mightNotFound
(
"
featureType
"
,
datastore
=
ds_name
):
ws
.
delete_featuretype
(
ft_name
,
ds_name
)
ws
.
save
()
...
...
@@ -349,6 +356,10 @@ class coveragestore(object):
def
DELETE
(
self
,
map_name
,
ws_name
,
cs_name
,
format
):
mf
,
ws
=
get_mapfile_workspace
(
map_name
,
ws_name
)
# We need to check if this datatore is empty.
assert_is_empty
(
ws
.
iter_coverages
(
cs_name
=
cs_name
),
"
coveragestore
"
,
ds_name
)
with
webapp
.
mightNotFound
(
"
coverageStore
"
,
workspace
=
ws_name
):
ws
.
delete_coveragestore
(
cs_name
)
ws
.
save
()
...
...
@@ -442,6 +453,10 @@ class coverage(object):
def
DELETE
(
self
,
map_name
,
ws_name
,
cs_name
,
c_name
,
format
):
mf
,
ws
=
get_mapfile_workspace
(
map_name
,
ws_name
)
# We need to check if there are any layers using this.
assert_is_empty
(
mg
.
iter_layers
(
mra
=
{
"
name
"
:
c_name
,
"
workspace
"
:
ws_name
,
"
storage
"
:
cs_name
,
"
type
"
:
"
coverage
"
}),
"
coverage
"
,
ft_name
)
with
webapp
.
mightNotFound
(
"
coverage
"
,
coveragestore
=
cs_name
):
ws
.
delete_coverage
(
c_name
,
cs_name
)
ws
.
save
()
...
...
@@ -582,6 +597,15 @@ class style(object):
def
DELETE
(
self
,
map_name
,
s_name
,
format
):
mf
=
get_mapfile
(
map_name
)
# OK check any(class.group == s_name for class in layer.iter_classes)
layers_using
=
[
layer
.
ms
.
name
for
layer
in
mf
.
iter_layers
()
if
any
(
clazz
.
ms
.
group
==
s_name
for
clazz
in
layer
.
iter_classes
())]
if
layers_using
:
raise
webapp
.
Forbidden
(
message
=
"
Can
'
t remove style
'
%s
'
because it is beeing used by the folowing layers: %s.
"
%
(
s_name
,
layers_using
))
path
=
tools
.
get_style_path
(
s_name
)
try
:
...
...
This diff is collapsed.
Click to expand it.
src/tools.py
+
9
−
1
View file @
39ce8222
...
...
@@ -67,6 +67,15 @@ def get_mapfile_workspace(mf_name, ws_name):
ws
=
mf
.
get_workspace
(
ws_name
)
return
mf
,
ws
def
assert_is_empty
(
generator
,
tname
,
iname
):
try
:
next
(
generator
)
except
StopIteration
:
pass
# Everything is ok.
else
:
raise
webapp
.
Forbidden
(
message
=
"
Can
'
t remove
'
%s
'
because it is an non-empty %s.
"
%
(
iname
,
tname
))
def
href
(
url
):
return
pyxml
.
Entries
({
'
href
'
:
url
})
...
...
@@ -148,4 +157,3 @@ def is_hidden(path):
return
os
.
path
.
basename
(
path
).
startswith
(
"
.
"
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment