-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PP-129 OPDS 2 with acquisition links #1340
PP-129 OPDS 2 with acquisition links #1340
Conversation
16d8c6a
to
5138840
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## feature/refactor-opds-feeds #1340 +/- ##
===============================================================
+ Coverage 89.96% 90.04% +0.08%
===============================================================
Files 225 227 +2
Lines 30473 30660 +187
Branches 6979 7039 +60
===============================================================
+ Hits 27416 27609 +193
+ Misses 1965 1957 -8
- Partials 1092 1094 +2
☔ View full report in Codecov by Sentry. |
b50811b
to
f70ec00
Compare
39ec230
to
122365c
Compare
c4b041b
to
f1f1b6b
Compare
d1d5769
to
857ba47
Compare
857ba47
to
aecc464
Compare
@RishiDiwanTT The first thing I was trying to do with this PR is to load the OPDS2 version of the feed in my test environment to see what the serialized OPDS2 looks like. Can you give me some pointers how I can get an OPDS2 response? I tried a few incantations to coerce a OPDS2 response, but I came up empty. I would have expected that I could set an |
Currently only the /loans, /borrow and /feed APIs are activated for opds2.
They can be seen by adding a content type : application/opds+json header to
the GET request.
…On Thu, Aug 31, 2023, 01:25 Jonathan Green ***@***.***> wrote:
@RishiDiwanTT <https://github.com/RishiDiwanTT> The first thing I was
trying to do with this PR is to load the OPDS2 version of the feed in my
test environment to see what the serialized OPDS2 looks like. Can you give
me some pointers how I can get an OPDS2 response?
—
Reply to this email directly, view it on GitHub
<#1340 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVRR5S3WGRNDI7PBTLAFOEDXX6LEBANCNFSM6AAAAAA33ODQWQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Typically the content-type header indicates the type of the data included in the request. I'd expect to do content negotiation like this via an accept header included on the request, which would cause the content-type header to be included in the response. |
That makes sense, and is a very small change.
…On Thu, Aug 31, 2023, 06:48 Jonathan Green ***@***.***> wrote:
Typically the content-type header
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type>
indicates the type of the data included in the request. I'd expect to do
content negotiation like this via an accept header
<https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept>
included on the request, which would cause the content-type header to be
included in the response.
—
Reply to this email directly, view it on GitHub
<#1340 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVRR5SZ5JLBVRK2LM4JD3FTXX7Q4RANCNFSM6AAAAAA33ODQWQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Okay. So I pointed this branch at an existing DB with some books in it, and then I ran the resulting OPDS2 feed through our OPDS2 validator |
OPDS2 publication feed is now the same as the OPDS1 page feed, with a different serializer
127b5bb
to
f77e2dd
Compare
The only real fix was to the audience category
This ended up being trivial, changes required were 2
Apart from that the actual validator code was broken, I guess somewhere along the way the OPDSImporter code changed a bit and the validator did not reflect those changes. |
Moving this to a comment here so we don't forget the package needs to be renamed. |
Do we have anymore feedback for this PR or should I merge it into the refactor branch? Once merged I can rename the module. |
@RishiDiwanTT I'm taking another look over this PR now. I'll post a comment once I'm done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RishiDiwanTT I made a few more comments here
core/feed_protocol/acquisition.py
Outdated
elif entry is None: | ||
return None | ||
elif isinstance(entry, OPDSMessage): | ||
return ProblemDetail( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this new case isn't covered by a test, and it seems like the original code doesn't return a problem detail in this case, but converts the OPDSMessage
into an error response?
Can you write up a test for this and verify that we aren't changing the behavior of the single item loans feed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I realised when I changed the order of the return statements, that the single_entry
method does not return a ProblemDetail at all, it only returns an OPDSMessage with the problem.
This does change the behaviour from one of returning an XML document (from OPDSMessage.tag
) to that of returning a ProblemDetail when a problem occurs in the single_entry
method. This change has been made since the response types are not bound to always being XML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think either:
- we need to handle this at the serialization step, so that we get the same XML response we used to get in the case of an OPDS 1 feed
- Or check with the mobile apps and see how returning a problem detail here instead of a feed will be handled
Since our mobile apps are the primary consumer of this feed still, we need to make sure they are in sync with any changes that get made to the responses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can return to the XML format easily, will that be an acceptable behaviour when the client is expecting JSON though?
Re: ProblemDetail: The same method also returns problem details in different circumstances so a problem detail should be already handled by the client side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of the mobile apps in the case still worries me. It seems like the thing to do here is to modify OPDSMessage
to be non-XML specific, so we are able to serialize it in both OPDS1 and OPDS2 instead of changing the feed behavior.
If that is too much work here, or if you don't want to do that as part of this PR. Can we modify the responses here so that the OPDS1 response (the one that is currently used by the mobile apps) remains the same, rendering the OPDSMessage
in the feed as XML and put a follow up ticket in JIRA to handle this case in OPDS2.
@RishiDiwanTT what do you think of those ideas or do you have another idea how we could handle this. The main thing I am concerned about is how this will impact the mobile apps using the OPDS1 feed. The OPDS2 is more "beta" and we can continue to iterate there. I'd like to impact our existing users as little as possible while doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I reverted to protocol specific data, OPDS1 will be the same XML and OPDS2 will be JSON.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still concerned here about the change in behavior of the OPDSMessage
class as part of this PR. I don't want to hold up merging this, but I also don't want it to have a negative impact on the experience of our users consuming the OPDS 1 feed through the app.
core/feed_protocol/acquisition.py
Outdated
elif entry is None: | ||
return None | ||
elif isinstance(entry, OPDSMessage): | ||
return ProblemDetail( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior of the mobile apps in the case still worries me. It seems like the thing to do here is to modify OPDSMessage
to be non-XML specific, so we are able to serialize it in both OPDS1 and OPDS2 instead of changing the feed behavior.
If that is too much work here, or if you don't want to do that as part of this PR. Can we modify the responses here so that the OPDS1 response (the one that is currently used by the mobile apps) remains the same, rendering the OPDSMessage
in the feed as XML and put a follow up ticket in JIRA to handle this case in OPDS2.
@RishiDiwanTT what do you think of those ideas or do you have another idea how we could handle this. The main thing I am concerned about is how this will impact the mobile apps using the OPDS1 feed. The OPDS2 is more "beta" and we can continue to iterate there. I'd like to impact our existing users as little as possible while doing so.
Created a Serializer base for better typing and OOP
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 I think this is looking good @RishiDiwanTT
* Added acquisition link serialization for OPDS2 * OPDS2 serialization with acuqisition links * Loan and hold specific statuses for acquisition links * Content types come from the serializer now OPDS2 publication feed is now the same as the OPDS1 page feed, with a different serializer * Ensure test_url_for is only used during testing * Mimetypes are iterated in priority order before serialization Created a Serializer base for better typing and OOP
This PR should be reviewed in tandem with the Feed Refactor PR.
Description
Acquisition links for the OPDS 2 feeds as per the De Marque document.
This PR also adds the ability for certain feeds to be served as either XML or JSON based on the requests
content-type
.This PR was also used to complete the OPDS2 serializer which was left out of #1308 .
Example
Missing
The
authenticate
property has not been added, since we are currently providing the authentication document link as part of the feed links. Wasn't sure is we wanted to change that behaviour.Motivation and Context
JIRA-129 and JIRA-78
How Has This Been Tested?
Manually checked
Checklist