def raw(part_id): """ Return the part's body as a raw byte-stream for eg. serving images. """ part = MimePart.get(part_id) logged_in = logged_in_user() if not part: abort(404, 'No such content item', force_status=True) # If anyone has shared this part with us (or the public), we get to view # it. for link in part.posts: if link.post.has_permission_to_view(logged_in): return raw_response(part.body, part.type) abort(403, 'Forbidden')