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

fix CSW 2/3 distributed search hopcount handling #1005

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions pycsw/ogc/csw/csw2.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,13 +823,13 @@ def getrecords(self):

dsresults = []

hopcount = int(self.parent.kvp.get('hopcount', 2)) - 1

if ('federatedcatalogues' in self.parent.config and
'distributedsearch' in self.parent.kvp and 'hopcount' in self.parent.kvp and
self.parent.kvp['distributedsearch'] and int(self.parent.kvp['hopcount']) > 0):
# do distributed search
self.parent.kvp.get('distributedsearch') and
hopcount > 0):

LOGGER.debug('DistributedSearch specified (hopCount: %s).',
self.parent.kvp['hopcount'])
LOGGER.debug('DistributedSearch specified (hopCount: %s).', hopcount)

from owslib.csw import CatalogueServiceWeb
from owslib.ows import ExceptionReport
Expand Down Expand Up @@ -1736,8 +1736,8 @@ def parse_postdata(self, postdata):
if tmp is not None:
request['distributedsearch'] = True
hopcount = tmp.attrib.get('hopCount')
request['hopcount'] = int(hopcount)-1 if hopcount is not None \
else 1
request['hopcount'] = int(hopcount) if hopcount is not None \
else 2
else:
request['distributedsearch'] = False

Expand Down
20 changes: 7 additions & 13 deletions pycsw/ogc/csw/csw3.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,19 +972,13 @@ def getrecords(self):
'Record serialization failed: %s' % str(err))
return self.parent.response

if ('federatedcatalogues' in self.parent.config and
'distributedsearch' in self.parent.kvp and 'hopcount' in self.parent.kvp and
self.parent.kvp['distributedsearch'] and int(self.parent.kvp['hopcount']) > 0):
# do distributed search
hopcount = int(self.parent.kvp.get('hopcount', 2)) - 1

# if all(['federatedcatalogues' in self.parent.config,
# 'distributedsearch' in self.parent.kvp,
# self.parent.kvp['distributedsearch'],
# 'hopcount' in self.parent.kvp,
# int(self.parent.kvp['hopcount']) > 0]): # do distributed search
if ('federatedcatalogues' in self.parent.config and
self.parent.kvp.get('distributedsearch') and
hopcount > 0):

LOGGER.debug('DistributedSearch specified (hopCount: %s)',
self.parent.kvp['hopcount'])
LOGGER.debug('DistributedSearch specified (hopCount: %s).', hopcount)

from owslib.csw import CatalogueServiceWeb
from owslib.ows import ExceptionReport
Expand Down Expand Up @@ -1812,8 +1806,8 @@ def parse_postdata(self, postdata):
if tmp is not None:
request['distributedsearch'] = True
hopcount = tmp.attrib.get('hopCount')
request['hopcount'] = int(hopcount)-1 if hopcount is not None \
else 1
request['hopcount'] = int(hopcount) if hopcount is not None \
else 2
else:
request['distributedsearch'] = False

Expand Down
Loading