diff --git a/src/geoserver/catalog.py b/src/geoserver/catalog.py index b1a0d10..e37ed85 100644 --- a/src/geoserver/catalog.py +++ b/src/geoserver/catalog.py @@ -892,6 +892,7 @@ def get_resources(self, names=None, stores=None, workspaces=None): ''' if not stores: _stores = self.get_stores( + names=names, workspaces=workspaces ) elif not isinstance(stores, list): diff --git a/src/geoserver/layer.py b/src/geoserver/layer.py index c75e0e9..e2a3c79 100644 --- a/src/geoserver/layer.py +++ b/src/geoserver/layer.py @@ -13,7 +13,12 @@ except: from urlparse import urljoin -from geoserver.support import ResourceInfo, xml_property, write_bool, workspace_from_url +from geoserver.support import ( + ResourceInfo, + xml_property, + write_bool, + workspace_from_url, + resource_from_url) from geoserver.style import Style @@ -134,7 +139,9 @@ def resource(self): if self.gs_version >= "2.13": if ":" in name: ws_name, name = name.split(':') - return self.catalog.get_resources(names=name, workspaces=ws_name)[0] + store_name = resource_from_url(atom_link[0].get('href'), ws_name) + _resources = self.catalog.get_resources(names=[name], stores=[store_name], workspaces=[ws_name]) + return _resources[0] if len(_resources) > 0 else _resources def _get_default_style(self): if 'default_style' in self.dirty: diff --git a/src/geoserver/support.py b/src/geoserver/support.py index 6042c03..4104131 100644 --- a/src/geoserver/support.py +++ b/src/geoserver/support.py @@ -652,3 +652,13 @@ def workspace_from_url(url): return split_path[split_path.index('workspaces') + 1] else: return None + + +def resource_from_url(url, workspace): + parts = urlparse(url) + split_path = parts.path.split('/') + if workspace in split_path: + resource_type = split_path[split_path.index(workspace) + 1] + return split_path[split_path.index(resource_type) + 1] + else: + return None