inveniosoftware / invenio-records-rest

Invenio records REST API module.
https://invenio-records-rest.readthedocs.io
MIT License
4 stars 63 forks source link

Cannot use `partial` for `links_factory_imp` #183

Open ntarocco opened 6 years ago

ntarocco commented 6 years ago

The commint https://github.com/inveniosoftware/invenio-records-rest/commit/1804923d94fe7d4982979d900fd4c42d8f600a96 is using the python function getargspec to check if the the links_factory_imp has kwargs. Unfortunately, that python function is checking if the given function is a real function, and it raises a TypeError otherwise.

If we use partial instead, it breaks. Example:

project_links_factory = partial(deposit_links_factory, deposit_type='project')
"""Project factory for links generation."""

Workaround:

def project_links_factory(pid):
    """Project factory for links generation."""
    deposit_links_factory(pid, deposit_type='project')

Would it possible to add support for partials?

nharraud commented 6 years ago

Note: this should also be tested for python 3 with the signature call