Skip to content

Commit

Permalink
fix CSW 2/3 distributed search hopcount handling (geopython#1005)
Browse files Browse the repository at this point in the history
* fix CSW 2/3 distributed search hopcount handling
  • Loading branch information
tomkralidis authored Sep 3, 2024
1 parent 80e5841 commit efddd6a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
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

0 comments on commit efddd6a

Please sign in to comment.