gicait / geoserver-rest

Python library for management of geospatial data in GeoServer.
https://geoserver-rest.readthedocs.io
MIT License
191 stars 77 forks source link

Changed upload_style so you can alternatively just pass valid XML in place of the path to the file containing the style XML #139

Closed iboates closed 6 months ago

iboates commented 6 months ago

Closes #116

I finally came back to this half a year later, but I made better changes than what I suggested in the issue.

You can now upload a style just by passing valid XML where you would normally pass the path to the SLD file.

I realize it's a bit janky because the parameter is called path, but I'm afraid that changing it might break existing systems that invoke the method via kwargs. But I think the added flexibility is worth it. To briefly re-iterate my issue, I was dynamically building style files on the fly and uploading them, and it was annoying me that I had to save them to a file before uploading them. With this change I (and others) should be able to just pass the style as XML if you don't want to bother writing to disk first.

I also wrote a couple tests to confirm that both passing a path to the file works, as does passing an XML string. I also tested that passing a non-existent path, as well as a malformed XML string fails as expected.

Sorry about the bad branch name, originally I was working on making temp files work before I realized that it would be easier to just pass a string.