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

general: upstream invenio-pidstore #1613

Closed
wants to merge 1 commit into from

Conversation

kaplun
Copy link
Contributor

@kaplun kaplun commented Sep 28, 2016

  • No longer uses INSPIRE fork of invenio-pidstore.
  • Introduces new get_pid_type_for() helper to map from endpoints
    to corresponding pid_types, now that pid_types are constrained in
    length.
    (closes Upstream pidstore #1579)

Signed-off-by: Samuele Kaplun [email protected]


def get_pid_type_for(endpoint):
"""Get the pid_type code corresponding to the recid of the given endpoint."""
return RECORDS_REST_ENDPOINTS[endpoint]['pid_type']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called with input coming from the users (e.g. the /ajax/references view function), therefore I'd recommend wrapping it in a try/except with a default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the caller code be wrapped? (i.e. the one that is directly receiving the input from the user?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular there is no good default, and it would hide wrong usages. I'd prefer to bubble up the exception to the calling code which is really aware of the origin of the endpoint argument and should know how to act on a KeyError.

Copy link
Contributor

@jacquerie jacquerie Sep 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I'd say it's equivalent, because this is not a whitelist/sanitization/security issue, just a potential source of exceptions on Sentry. Your call!

Changed my mind. You're right!

@jacquerie
Copy link
Contributor

jacquerie commented Sep 28, 2016

This helper (used in the API) is using the opposite mapping from the one you are now introducing. I'd say we should also have in the config the "inverted" dictionary generated by a dictionary comprehension.

EDIT: corrected the broken link

@jacquerie jacquerie changed the title general: upstream invenio-pidstore WIP general: upstream invenio-pidstore Sep 28, 2016
@jacquerie
Copy link
Contributor

This is another place where you could use the inverse mapping.

@jacquerie
Copy link
Contributor

Put it in WIP because it's missing a few uses of the pid_type names, but yeah, I like this idea of reducing the custom packages 👍

@kaplun
Copy link
Contributor Author

kaplun commented Sep 28, 2016

This helper is using the opposite mapping from the one you are now introducing. I'd say we should also have in the config the "inverted" dictionary generated by a dictionary comprehension.

The link behind This helper is broken. What did you want to link?

@kaplun
Copy link
Contributor Author

kaplun commented Sep 28, 2016

but yeah, I like this idea of reducing the custom packages 👍

This one was really a blocker IMHO because our fork is changing the SQLAlchemy model and wouldn't therefore allow for an easy upgrade to the upstream one.

@jacquerie
Copy link
Contributor

jacquerie commented Sep 28, 2016

The link behind This helper is broken.

Whoops, fixed.

@kaplun
Copy link
Contributor Author

kaplun commented Sep 28, 2016

I think I have implemented your requests.

P.s. OT why haven't you used the Github review for this PR? Just by chance or you don't like it?

@jacquerie
Copy link
Contributor

OT why haven't you used the Github review for this PR? Just by chance or you don't like it?

I love it! But in this case my comments were about things that were missing from your PR, therefore I had no way of commenting on those...

@kaplun kaplun force-pushed the upstream-pidstore branch 2 times, most recently from 89a4ce8 to 2d5874e Compare September 28, 2016 22:40
@kaplun
Copy link
Contributor Author

kaplun commented Sep 28, 2016

Gaah: it's failing only on acceptance tests. I wonder what I am missing at this point?

* No longer uses INSPIRE fork of invenio-pidstore.

* Introduces new get_pid_type_for() and get_endpoint_from_pid_type()
  helpers to map between endpoints and the corresponding pid_types,
  now that pid_types are constrained in length. (closes inspirehep#1579)

Signed-off-by: Samuele Kaplun <[email protected]>
@kaplun kaplun force-pushed the upstream-pidstore branch from 0ff6af8 to 02b4651 Compare October 11, 2016 15:11
@kaplun kaplun changed the title WIP general: upstream invenio-pidstore general: upstream invenio-pidstore Oct 11, 2016
@kaplun
Copy link
Contributor Author

kaplun commented Oct 11, 2016

Sent a new version using upstream invenio-record-rests pid_type to endpoint_prefix mapping.

@jacquerie
Copy link
Contributor

What's the status on this? This was a good thing.

@kaplun
Copy link
Contributor Author

kaplun commented Oct 18, 2016

Ah nothing, I need focus on it to make it work. I might do it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upstream pidstore
2 participants