def resource_show_revision(context, data_dict): """Show a resource from a specified revision Takes the same arguments as 'resource_show' but with an additional revision_ref parameter :param id: the id of the resource :type id: string :param revision_ref: the ID of the revision or release name :type revision_ref: string :returns: A resource dict :rtype: dict """ revision_ref = _get_revision_ref(data_dict) if revision_ref is None: return core_resource_show(context, data_dict) model = context['model'] id = toolkit.get_or_bust(data_dict, 'id') resource = model.Resource.get(id) package = _get_package_in_revision(context, {'id': resource.package_id}, revision_ref) resource_dict = h.find_resource_in_package(package, id) if resource_dict is None: raise toolkit.ObjectNotFound("Resource not found for dataset revision") return resource_dict
def _get_resource_in_revision(context, data_dict, revision_id): """Get resource from a given revision """ current_revision_id = context.get('revision_id', None) context['revision_id'] = revision_id result = core_resource_show(context, data_dict) result['datastore_active'] = False _fix_resource_data(result, revision_id) if current_revision_id: context['revision_id'] = current_revision_id else: del context['revision_id'] return result