diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-06-30 17:26:44 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-06-30 17:26:44 +0200 | 
| commit | ffd57727a66952e12b5236e7567f5fd75eb7e5f8 (patch) | |
| tree | 2b8ab152e92a95948e9a038ebcef815bfd56aa38 /ishtar_common/data_importer.py | |
| parent | 2a0842c8ffb0e7eec6b350f9d170670c8376cce8 (diff) | |
| parent | 18995ac80a961083ad986f4abe984fd649ec40e2 (diff) | |
| download | Ishtar-ffd57727a66952e12b5236e7567f5fd75eb7e5f8.tar.bz2 Ishtar-ffd57727a66952e12b5236e7567f5fd75eb7e5f8.zip  | |
Merge branch 'master' into develop
Diffstat (limited to 'ishtar_common/data_importer.py')
| -rw-r--r-- | ishtar_common/data_importer.py | 41 | 
1 files changed, 28 insertions, 13 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 1fe4ef45c..76b186038 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1400,20 +1400,35 @@ class Importer(object):          # get all related fields          new_created = {} -        for attribute in list(data.keys()): -            c_c_path = c_path[:] -            if not attribute: -                data.pop(attribute) -                continue -            if not data[attribute]: -                field_object, model, direct, m2m = \ -                    cls._meta.get_field_by_name(attribute) -                if m2m: +        try: +            for attribute in list(data.keys()): +                c_c_path = c_path[:] +                if not attribute:                      data.pop(attribute) -                continue -            if attribute != '__force_new': -                self.get_field(cls, attribute, data, m2ms, c_c_path, -                               new_created) +                    continue +                if not data[attribute]: +                    field_object, model, direct, m2m = \ +                        cls._meta.get_field_by_name(attribute) +                    if m2m: +                        data.pop(attribute) +                    continue +                if attribute != '__force_new': +                    self.get_field(cls, attribute, data, m2ms, c_c_path, +                                   new_created) +        except (ValueError, IntegrityError) as e: +            message = e.message +            try: +                message = e.message.decode('utf-8') +            except (UnicodeDecodeError, UnicodeDecodeError): +                message = '' +            try: +                data = unicode(data) +            except UnicodeDecodeError: +                data = '' +            raise ImporterError( +                "Erreur d'import %s %s, contexte : %s, erreur : %s" +                % (unicode(cls), unicode("__".join(path)), +                   unicode(data), message))          create_dict = copy.deepcopy(data)          for k in create_dict.keys():  | 
