2

I'm able to set default style for any layer using below code

cat = Catalog("http://localhost:8080/geoserver/rest", "admin", "geoserver")
layer = cat.get_layer("layer_name")
layer._set_default_style("style_name")
cat.save(layer)

Now I want to set default style from particula workspace (say states),How I can able to do?
I tried as

cat = Catalog("http://localhost:8080/geoserver/rest", "admin", "geoserver")
layer = cat.get_layer("layer_name")
layer._set_default_style("states","style_name")
cat.save(layer)

The error is: TypeError:_set_default_style() takes exactly 2 arguments (3 given).

2

you can do:

my_style = 'my_ws:my_style'
style = cat.get_style(my_style)
layer = cat.get_layer('layername')
layer.default_style = style
cat.save(layer)
  • Is there a way to set an alternate style as well? – user1919 May 30 '18 at 7:14
0

Just a guess here, but you might be able to set a style from a particular workspace by appending the workspace, then a colon, then the style name. E.g.:

layer._set_default_style("states:style_name")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.