From 1f88c981546927e21c3804d847e5f9baa1ca4a08 Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Mon, 14 Oct 2019 08:07:39 +0000 Subject: [PATCH] publish muk_fields_lobject - 13.0 --- muk_fields_lobject/fields/lobject.py | 11 +++++++---- muk_fields_lobject/static/description/index.html | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/muk_fields_lobject/fields/lobject.py b/muk_fields_lobject/fields/lobject.py index da10b63..e112359 100644 --- a/muk_fields_lobject/fields/lobject.py +++ b/muk_fields_lobject/fields/lobject.py @@ -35,7 +35,10 @@ class LargeObject(fields.Field): type = "lobject" column_type = ("oid", "oid") - _slots = {"prefetch": False, "context_dependent": True} + _slots = { + "prefetch": False, + "depends_context": ("bin_size", "human_size", "path", "bytes", "stream"), + } def convert_to_column(self, value, record, values=None, validate=True): oid = record.with_context({"oid": True})[self.name] @@ -65,8 +68,8 @@ class LargeObject(fields.Field): return lobject.seek(0, 2) elif record._context.get("oid"): return lobject.oid - elif record._context.get("base64"): - return base64.b64encode(lobject.read()) + elif record._context.get("bytes"): + return lobject.read() elif record._context.get("stream"): file = tempfile.TemporaryFile() while True: @@ -83,7 +86,7 @@ class LargeObject(fields.Field): return checksum.hexdigest() checksum.update(chunk) else: - return lobject.read() + return base64.b64encode(lobject.read()) return None if value is False else value def convert_to_export(self, value, record): diff --git a/muk_fields_lobject/static/description/index.html b/muk_fields_lobject/static/description/index.html index a283ee4..00dd3ea 100644 --- a/muk_fields_lobject/static/description/index.html +++ b/muk_fields_lobject/static/description/index.html @@ -70,9 +70,10 @@ class LargeObjectModel(models.Model): @api.multi def data(self): for record in self: - bytes = record.data_content + base64 = record.data_content oid = record.with_context({'oid': True}).data_content size = record.with_context({'bin_size': True}).data_content + bytes = record.with_context({'bytes': True}).data_content stream = record.with_context({'stream': True}).data_content