Skip to content

Commit

Permalink
fix(opensearch): raise 404 on search when collection does not exist
Browse files Browse the repository at this point in the history
Improved typing
Code formatting fixes
  • Loading branch information
constantinius committed Feb 21, 2025
1 parent 1e6d5ec commit 82786ce
Show file tree
Hide file tree
Showing 13 changed files with 388 additions and 318 deletions.
11 changes: 6 additions & 5 deletions eoxserver/core/decoders/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#-------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
#
# Project: EOxServer <http://eoxserver.org>
# Authors: Fabian Schindler <[email protected]>
#
#-------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Copyright (C) 2013 EOX IT Services GmbH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -23,12 +23,13 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

""" This module contains facilities to help decoding configuration files.
It relies on the :mod:`ConfigParser` module for actually reading the file.
"""

from typing import Union
import sys

try:
Expand Down Expand Up @@ -86,7 +87,7 @@ def __init__(self, key=None, type=None, separator=None, required=False,
self.section = section

def fget(self, reader):

section = self.section or reader.section
try:
if self.type is bool:
Expand Down Expand Up @@ -180,7 +181,7 @@ class ExampleReader(config.Reader):

__metaclass__ = ReaderMetaclass

section = None
section: Union[str, None] = None

def __init__(self, config):
self._config = config
5 changes: 4 additions & 1 deletion eoxserver/services/opensearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# THE SOFTWARE.
# ------------------------------------------------------------------------------

from typing import List

from django.conf import settings
from django.utils.module_loading import import_string

Expand All @@ -41,7 +43,7 @@

]

DEFAULT_EOXS_RESULT_ITEM_FEED_LINK_GENERATORS = []
DEFAULT_EOXS_RESULT_ITEM_FEED_LINK_GENERATORS: List[str] = []

# default for EOXS_OPENSEARCH_EXTENSIONS
DEFAULT_EOXS_OPENSEARCH_EXTENSIONS = [
Expand All @@ -63,6 +65,7 @@
# when True, adds exceptions=text/html to all GetCoverage links in opensearch response
DEFAULT_EOXS_OPENSEARCH_GETCOVERAGE_HTML_EXCEPTION = False


def get_opensearch_record_model():
class_name = getattr(
settings, 'EOXS_OPENSEARCH_RECORD_MODEL', DEFAULT_EOXS_OPENSEARCH_RECORD_MODEL
Expand Down
15 changes: 9 additions & 6 deletions eoxserver/services/opensearch/formats/atom.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#-------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
#
# Project: EOxServer <http://eoxserver.org>
# Authors: Fabian Schindler <[email protected]>
#
#-------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Copyright (C) 2015 EOX IT Services GmbH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -23,7 +23,7 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#-------------------------------------------------------------------------------
# ------------------------------------------------------------------------------


from itertools import chain
Expand Down Expand Up @@ -74,7 +74,8 @@ def encode(self, request, collection_id, queryset, search_context):
namespaces.update(search_context.namespaces)
ATOM = ElementMaker(namespace=ns_atom.uri, nsmap=namespaces)

tree = ATOM("feed",
tree = ATOM(
"feed",
ATOM("id", request.build_absolute_uri()),
ATOM("title", "%s Search" % collection_id),
ATOM("description"),
Expand All @@ -96,7 +97,8 @@ def encode(self, request, collection_id, queryset, search_context):
return etree.tostring(tree, pretty_print=True)

def encode_entry(self, request, collection_id, item):
entry = ATOM("entry",
entry = ATOM(
"entry",
ATOM("title", item.identifier),
ATOM("id", self._create_self_link(request, collection_id, item)),
DC("identifier", item.identifier),
Expand Down Expand Up @@ -164,7 +166,8 @@ def encode_summary(self, request, collection_id, item):
'eo_om_link': eo_om_link,
}

return ATOM("summary",
return ATOM(
"summary",
CDATA(
render_to_string(
template_name, template_params,
Expand Down
Loading

0 comments on commit 82786ce

Please sign in to comment.