Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layergroup creation bugfix #97

Merged
merged 3 commits into from
Feb 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion geo/Geoserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,8 +728,14 @@ def create_layergroup(
raise Exception(
f"Format not supported. Acceptable formats are : {supported_formats}"
)

# check if it already exist in Geoserver
if self.get_layergroup(name) is not None:
try:
existing_layergroup = self.get_layergroup(name)
except:
existing_layergroup = None

if existing_layergroup is not None:
raise Exception(
f"Layergroup: {name} already exist in Geoserver instance"
)
Copy link
Contributor

@Kilometerfresserin Kilometerfresserin Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether it is smart to remove the check entirely, because this will cause issues for any code that assumes it will get an error if the layergroup exists already.

I would suggest to check for an exception in get_layergroup, like (I don't know if this is the most pythonic solution, but it works):

            # check if it already exist in Geoserver
            try: 
                existing_layer_group = self.get_layergroup(name)
            except:
                existing_layer_group = None

            if existing_layer_group is not None:
                raise Exception(
                    f"Layergroup: {name} already exists in Geoserver instance"
                )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it is the correct way of fixing for now. Can you please update this PR with above suggestion? @julescarpentier

Expand Down