Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: flask-sqlalchemy.pagination >= 3.0.0
Browse files Browse the repository at this point in the history
* this is a compatibility fix. the old compatibility commit was wrong.
  they are not interchangable
utnapischtim committed Dec 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 441c69c commit 890f9b4
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions invenio_rdm_records/oaiserver/services/services.py
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import re

from flask import current_app
from flask_sqlalchemy.pagination import Pagination
from invenio_db import db
from invenio_i18n import lazy_gettext as _
from invenio_oaiserver.models import OAISet
@@ -31,12 +32,25 @@
)
from .uow import OAISetCommitOp, OAISetDeleteOp

try:
# flask_sqlalchemy<3.0.0
from flask_sqlalchemy import Pagination
except ImportError:
# flask_sqlalchemy>=3.0.0
from flask_sqlalchemy.pagination import Pagination

class OAIPagination(Pagination):
"""OAI Pagination."""

def _query_items(self):
"""Return items."""
try:
return self._query_args["items"]
except KeyError:
msg = "items not set in OAIPaginations constructor."
raise RuntimeError(msg)

def _query_count(self):
"""Return count."""
try:
return self._query_args["total"]
except KeyError:
msg = "total not set in OAIPaginations constructor."
raise RuntimeError(msg)


class OAIPMHServerService(Service):
@@ -226,7 +240,7 @@ def read_all_formats(self, identity):
for k, v in current_app.config.get("OAISERVER_METADATA_FORMATS").items()
]

results = Pagination(
results = OAIPagination(
query=None,
page=1,
per_page=None,

0 comments on commit 890f9b4

Please sign in to comment.