File tree 1 file changed +21
-7
lines changed
invenio_rdm_records/oaiserver/services
1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change 10
10
import re
11
11
12
12
from flask import current_app
13
+ from flask_sqlalchemy .pagination import Pagination
13
14
from invenio_db import db
14
15
from invenio_i18n import lazy_gettext as _
15
16
from invenio_oaiserver .models import OAISet
31
32
)
32
33
from .uow import OAISetCommitOp , OAISetDeleteOp
33
34
34
- try :
35
- # flask_sqlalchemy<3.0.0
36
- from flask_sqlalchemy import Pagination
37
- except ImportError :
38
- # flask_sqlalchemy>=3.0.0
39
- from flask_sqlalchemy .pagination import Pagination
35
+
36
+ class OAIPagination (Pagination ):
37
+ """OAI Pagination."""
38
+
39
+ def _query_items (self ):
40
+ """Return items."""
41
+ try :
42
+ return self ._query_args ["items" ]
43
+ except KeyError :
44
+ msg = "items not set in OAIPaginations constructor."
45
+ raise RuntimeError (msg )
46
+
47
+ def _query_count (self ):
48
+ """Return count."""
49
+ try :
50
+ return self ._query_args ["total" ]
51
+ except KeyError :
52
+ msg = "total not set in OAIPaginations constructor."
53
+ raise RuntimeError (msg )
40
54
41
55
42
56
class OAIPMHServerService (Service ):
@@ -226,7 +240,7 @@ def read_all_formats(self, identity):
226
240
for k , v in current_app .config .get ("OAISERVER_METADATA_FORMATS" ).items ()
227
241
]
228
242
229
- results = Pagination (
243
+ results = OAIPagination (
230
244
query = None ,
231
245
page = 1 ,
232
246
per_page = None ,
You can’t perform that action at this time.
0 commit comments