From 9fe17a1a2e7530254292b0a44eeef0ba438a27c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Fri, 28 Feb 2014 12:44:33 +0100 Subject: [PATCH] initialize file/image in case of missing attribute --- themis/importexport/sync.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/themis/importexport/sync.py b/themis/importexport/sync.py index 84df881..284a9ee 100644 --- a/themis/importexport/sync.py +++ b/themis/importexport/sync.py @@ -125,6 +125,8 @@ class SyncFromThemis(UtilityView): if data.get('picture'): # this will be an url content = self.urlopen(data.get('picture')).read() + if not hasattr(object, 'picture'): + object.picture = None if object.picture is None or object.picture.data != content: object.picture = NamedBlobImage(content, filename=data.get('id')) if data.get('past_functions'): @@ -240,10 +242,14 @@ class SyncFromThemis(UtilityView): object.session = data.get('session') if data.get('fichier'): content = self.urlopen(data.get('fichier')).read() + if not hasattr(object, 'file'): + object.file = None if object.file is None or object.file.data != content: object.file = NamedBlobFile(content, filename=data.get('id')+'.pdf') if data.get('document_imprime'): content = self.urlopen(data.get('document_imprime')).read() + if not hasattr(object, 'file'): + object.file = None if object.file is None or object.file.data != content: object.file = NamedBlobFile(content, filename=data.get('id')+'.pdf') if data.get('object_type'):