diff --git a/engine/core/feeds/base.py b/engine/core/feeds/base.py index 65ee96b4..01f00ede 100644 --- a/engine/core/feeds/base.py +++ b/engine/core/feeds/base.py @@ -162,7 +162,12 @@ class BaseFeedGenerator(ABC): @staticmethod def prettify_xml(elem: Element) -> str: - """Return a pretty-printed XML string for the Element.""" + """Return a pretty-printed XML string for the Element (without XML declaration).""" rough_string = tostring(elem, encoding="unicode") reparsed = minidom.parseString(rough_string) - return reparsed.toprettyxml(indent=" ", encoding=None) + pretty = reparsed.toprettyxml(indent=" ") + # Strip the XML declaration added by toprettyxml so callers can add their own + lines = pretty.split("\n") + if lines and lines[0].startswith("\n' + self.prettify_xml(rss) def _add_product_to_xml(self, item: Element, product_data: dict[str, Any]) -> None: """Add a product's data to an XML item element.""" diff --git a/schon/pagination.py b/schon/pagination.py index 24bf41ea..b3ef9530 100644 --- a/schon/pagination.py +++ b/schon/pagination.py @@ -13,7 +13,7 @@ class CustomPagination(PageNumberPagination): def get_paginated_response(self, data: list[dict[Any, Any]]) -> Response: if not self.page_size: self.page_size = 88 - if not 1 <= self.page_size <= 255: + if not 1 <= self.page_size <= 128: raise ValueError("Page size must be between 1 and 255") if not self.page: paginator = Paginator(data, self.page_size)