diff --git a/pyramid_oereb/contrib/data_sources/oereblex/sources/plr_oereblex.py b/pyramid_oereb/contrib/data_sources/oereblex/sources/plr_oereblex.py index 007e12ada8..709885d8a6 100644 --- a/pyramid_oereb/contrib/data_sources/oereblex/sources/plr_oereblex.py +++ b/pyramid_oereb/contrib/data_sources/oereblex/sources/plr_oereblex.py @@ -97,15 +97,15 @@ def document_records_from_oereblex(self, params, geolink, law_status, oereblex_p log.debug("document_records_from_oereblex() start, GEO-Link {}, law status {}, oereblex_params {}" .format(geolink, law_status.code, oereblex_params)) identifier = '{}{}{}'.format(geolink, law_status.code, params.language) - if identifier in self._queried_geolinks: + if identifier in self._queried_geolinks[params.identifier]: log.debug('skip querying this geolink "{}" because it was fetched already.'.format(identifier)) log.debug('use already queried instead') else: self._oereblex_source.read(params, geolink, law_status, oereblex_params) log.debug("document_records_from_oereblex() returning {} records" .format(len(self._oereblex_source.records))) - self._queried_geolinks[identifier] = self._oereblex_source.records - return self._queried_geolinks[identifier] + self._queried_geolinks[params.identifier][identifier] = self._oereblex_source.records + return self._queried_geolinks[params.identifier][identifier] def collect_related_geometries_by_real_estate(self, session, real_estate): """ @@ -133,6 +133,10 @@ def collect_related_geometries_by_real_estate(self, session, real_estate): ).all() def read(self, params, real_estate, bbox): - # resetting the local per request cache of queried oereblex links - self._queried_geolinks = {} - return super(DatabaseOEREBlexSource, self).read(params, real_estate, bbox) + # adding a local cache depending on the request identifier + self._queried_geolinks[params.identifier] = {} + # calling the original logic + result = super(DatabaseOEREBlexSource, self).read(params, real_estate, bbox) + # removing the cache after work is done + del self._queried_geolinks[params.identifier] + return result diff --git a/pyramid_oereb/core/views/webservice.py b/pyramid_oereb/core/views/webservice.py index d12b19f793..f1dc896a3d 100644 --- a/pyramid_oereb/core/views/webservice.py +++ b/pyramid_oereb/core/views/webservice.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- import logging +from uuid import uuid4 + # import yappi import qrcode import io @@ -637,6 +639,8 @@ def __init__(self, response_format, with_geometry=False, images=False, signed=Fa self.__topics__ = topics self.__extract_url__ = extract_url self.__qr_code_ref__ = qr_code_ref + #uniquely identifier to reference the original request in the pyramid_oereb system + self.identifier = str(uuid4()) def set_identdn(self, identdn): """