Skip to content

Commit a023ff5

Browse files
committed
Fixes: Errors on creating WMS Cascade stores and layers (references GeoNode/geonode#9426)
1 parent d00cb53 commit a023ff5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/geoserver/layer.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,17 @@ def _get_default_style(self, recursive=False):
153153
return self._resolve_style(element, recursive) if element is not None else None
154154

155155
def _resolve_style(self, element, recursive=False):
156-
if ":" in element.find('name').text:
157-
ws_name, style_name = element.find('name').text.split(':')
158-
else:
159-
style_name = element.find('name').text
160-
ws_name = None
161-
atom_link = [n for n in element if 'href' in n.attrib]
162-
if atom_link and ws_name is None:
163-
ws_name = workspace_from_url(atom_link[0].get("href"))
164-
return self.catalog.get_styles(names=style_name, workspaces=ws_name, recursive=recursive)[0]
156+
if element and element.find('name') and element.find('name').text:
157+
if ":" in element.find('name').text:
158+
ws_name, style_name = element.find('name').text.split(':')
159+
else:
160+
style_name = element.find('name').text
161+
ws_name = None
162+
atom_link = [n for n in element if 'href' in n.attrib]
163+
if atom_link and ws_name is None:
164+
ws_name = workspace_from_url(atom_link[0].get("href"))
165+
return self.catalog.get_styles(names=style_name, workspaces=ws_name, recursive=recursive)[0]
166+
return None
165167

166168
def _set_default_style(self, style):
167169
if isinstance(style, Style):

0 commit comments

Comments
 (0)