Skip to content

Commit

Permalink
- Fixed url paths
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jul 12, 2019
1 parent fed104c commit a8b4151
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
19 changes: 9 additions & 10 deletions src/geoserver/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ def save(self, obj, content_type="application/xml"):
href = urlparse(obj.href)
netloc = urlparse(self.service_url).netloc
rest_url = href._replace(netloc=netloc).geturl()
# rest_url = obj.href
data = obj.message()

headers = {
Expand Down Expand Up @@ -345,7 +344,6 @@ def get_store(self, name, workspace=None):
Will return None if no store is found.
Will raise an error if more than one store with the same name is found.
'''

stores = self.get_stores(workspaces=[workspace], names=name)
return self._return_first_item(stores)

Expand Down Expand Up @@ -886,20 +884,21 @@ def get_resources(self, names=None, stores=None, workspaces=None):
Will always return an array.
'''
if not stores:
stores = self.get_stores(
names=names,
_stores = self.get_stores(
workspaces=workspaces
)
elif not isinstance(stores, list):
_stores = [stores]
else:
_stores = stores

resources = []
for s in stores:
for s in _stores:
try:
if isinstance(s, basestring):
s = self._return_first_item(
self.get_stores(
names=s,
workspaces=workspaces
)
s = self.get_store(
s,
workspace=workspaces[0] if workspaces else None
)
resources.extend(s.get_resources())
except FailedRequestError:
Expand Down
2 changes: 1 addition & 1 deletion src/geoserver/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(self, catalog, name):
@property
def href(self):
return urljoin(
self.catalog.service_url,
"{}/".format(self.catalog.service_url),
"layers/{}.xml".format(self.name)
)

Expand Down
2 changes: 1 addition & 1 deletion src/geoserver/layergroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def href(self):
workspace_name = getattr(self.workspace, 'name', self.workspace)
path_parts = "workspaces/{}/{}".format(workspace_name, path_parts)
return urljoin(
self.catalog.service_url,
"{}/".format(self.catalog.service_url),
path_parts
)

Expand Down
5 changes: 2 additions & 3 deletions src/geoserver/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ def store(self):

@property
def href(self):
if self._href:
return self._href
url = build_url(
self.catalog.service_url,
[
Expand All @@ -124,6 +122,7 @@ def href(self):
self.name + ".xml"
]
)
return url or self._href


class FeatureType(_ResourceBase):
Expand Down Expand Up @@ -275,7 +274,7 @@ def __init__(self, catalog, workspace, store, name):
@property
def href(self):
return urljoin(
self.catalog.service_url,
"{}/".format(self.catalog.service_url),
"workspaces/{}/wmsstores/{}/wmslayers/{}.xml".format(
self.workspace.name,
self.store.name,
Expand Down
8 changes: 4 additions & 4 deletions src/geoserver/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ def name(self):
@property
def href(self):
return urljoin(
self.catalog.service_url,
"{}/".format(self.catalog.service_url),
"workspaces/{}.xml".format(self.name)
)

@property
def coveragestore_url(self):
return urljoin(
self.catalog.service_url,
"{}/".format(self.catalog.service_url),
"workspaces/{}/coveragestores.xml".format(self.name)
)

@property
def datastore_url(self):
return urljoin(
self.catalog.service_url,
"{}/".format(self.catalog.service_url),
"workspaces/{}/datastores.xml".format(self.name)
)

@property
def wmsstore_url(self):
return urljoin(
self.catalog.service_url,
"{}/".format(self.catalog.service_url),
"workspaces/{}/wmsstores.xml".format(self.name)
)

Expand Down

0 comments on commit a8b4151

Please sign in to comment.