Skip to content
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

views: impossible to use invenio-records-rest as a library. #129

Closed
nharraud opened this issue Nov 2, 2016 · 4 comments
Closed

views: impossible to use invenio-records-rest as a library. #129

nharraud opened this issue Nov 2, 2016 · 4 comments

Comments

@nharraud
Copy link
Member

nharraud commented Nov 2, 2016

Problem:
In B2Share code we were using invenio-records-rest with a few different endpoints (POST creates a deposit instead of a Record). Because of that we were using invenio-records-rest as a library and we disabled the automatic creation of endpoints (RECORDS_REST_ENDPOINTS={} in config). We reused the View classes and replaced the only method which was blocking us, i.e RecordsListResource.post. This does not work anymore as The views code depend explicitly on the config variable RECORDS_REST_ENDPOINTS (see ext.py and views.py)

From what I understood at the time this was implemented in B2Share, using invenio-records-rest as a library was an accepted use-case so I mark this as a bug.

Blocks #99

@nharraud
Copy link
Member Author

nharraud commented Nov 2, 2016

I don't know if others are using Invenio-records-rest as a library. If it is only us we can also say that the config RECORDS_REST_ENDPOINTS is mandatory.

For B2Share what we need is to be able to override one of the view methods. Another solution which would work for us would be to specify custom View classes.

Note that this also impacts invenio-deposits as we are also customising its REST API endpoints (removing completely the B2ShareRecordsListResource and customizing the RecordResource methods).

@nharraud
Copy link
Member Author

nharraud commented Nov 2, 2016

Summary of a discussion with @jirikuncar:

  • If B2Share was requiring Views subclasses there should have been tests to check it. Tests are basically the only specifications.
  • it should be possible to set _RecordRESTState.default_endpoint_prefixes on before_first_request.

I will add a test checking that invenio-records-rest can be used as a library. By library I mean reuse the provided View Resource classes but without having invenio-records-rest generating the endpoints.

@nharraud
Copy link
Member Author

nharraud commented Nov 2, 2016

In fact InvenioDeposit is already updating default_endpoint_prefixes as it is also using invenio-records-rest as a library.

@nharraud
Copy link
Member Author

nharraud commented Nov 2, 2016

Closing in favor of #130

@nharraud nharraud closed this as completed Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant