Changeset View
Changeset View
Standalone View
Standalone View
swh/web/api/views/identifiers.py
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | def api_resolve_swh_pid(request, swh_id): | ||||
# object is present in the archive, NotFoundExc | # object is present in the archive, NotFoundExc | ||||
# will be raised otherwise | # will be raised otherwise | ||||
swh_id_parsed = swh_id_resolved['swh_id_parsed'] | swh_id_parsed = swh_id_resolved['swh_id_parsed'] | ||||
object_type = swh_id_parsed.object_type | object_type = swh_id_parsed.object_type | ||||
object_id = swh_id_parsed.object_id | object_id = swh_id_parsed.object_id | ||||
service.lookup_object(object_type, object_id) | service.lookup_object(object_type, object_id) | ||||
# id is well-formed and the pointed object exists | # id is well-formed and the pointed object exists | ||||
swh_id_data = swh_id_parsed._asdict() | swh_id_data = swh_id_parsed._asdict() | ||||
swh_id_data['browse_url'] = swh_id_resolved['browse_url'] | swh_id_data['browse_url'] = request.build_absolute_uri( | ||||
swh_id_resolved['browse_url']) | |||||
return swh_id_data | return swh_id_data |