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

utils: spin out jsonref utils to inspire-utils #67

Open
jacquerie opened this issue Aug 26, 2017 · 0 comments
Open

utils: spin out jsonref utils to inspire-utils #67

jacquerie opened this issue Aug 26, 2017 · 0 comments

Comments

@jacquerie
Copy link
Contributor

jacquerie commented Aug 26, 2017

These two guys:

def get_recid_from_ref(ref_obj):
"""Retrieve recid from jsonref reference object.
If no recid can be parsed, returns None.
"""
if not isinstance(ref_obj, dict):
return None
url = ref_obj.get('$ref', '')
return maybe_int(url.split('/')[-1])
and
def get_record_ref(recid, endpoint='record'):
"""Create record jsonref reference object from recid.
None recids will return a None object.
Valid recids will return an object in the form of: {'$ref': url_for_record}
"""
if recid is None:
return None
return {'$ref': absolute_url('/api/{}/{}'.format(endpoint, recid))}
.

The problem is that they depend on absolute_url, so this requires #57 to be fixed.

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