From 1d79988228a9b08c86d9e595fdc1b92f7ca50424 Mon Sep 17 00:00:00 2001 From: Eric Sunshine Date: Tue, 13 Jan 2015 04:57:10 -0500 Subject: Blob: vend raw or cooked content Some blob representations require raw blob content, however, the 'blob' view is unconditionally handed cooked (utf8-encoded) content, thus representations which need raw content are forced to reload the blob in raw form, which is ugly and expensive. The ultimate goal is to eliminate the wasteful blob reloading when raw content is needed. Toward that end, teach Blob how to vend raw or cooked content. Signed-off-by: Eric Sunshine Signed-off-by: Alberto Bertogli --- utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index be6ab78..7223303 100644 --- a/utils.py +++ b/utils.py @@ -102,9 +102,9 @@ def embed_image_blob(repo, dirname, fname): mimetype = mimetypes.guess_type(fname)[0] # Unfortunately, bottle seems to require utf-8 encoded data. - # We have to refetch the blob with raw=True, because the utf-8 encoded + # We have to refetch the blob as raw data, because the utf-8 encoded # version of the blob available in the bottle template discards binary data. - raw_blob = repo.blob(dirname + fname, raw = True) + raw_blob = repo.blob(dirname + fname) return ''.format( \ mimetype, base64.b64encode(raw_blob.raw_content)) -- cgit v1.2.3