From 02f918c7c65ed65ccb954b49eea11ddcee7e590c Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Tue, 18 Jun 2019 12:14:58 +0200 Subject: [PATCH] fix GS export/import in python3 --- CHANGES.rst | 3 +++ src/collective/taxonomy/exportimport.py | 12 +++--------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index db725be..46d27b9 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,9 @@ Changes 2.0.0 (unreleased) ------------------ +- Fix GenericSetup import/export in python3 + [erral] + - Use taxonomy default language for indexing if current language is not available [agitator] diff --git a/src/collective/taxonomy/exportimport.py b/src/collective/taxonomy/exportimport.py index bb0ceea..aa7f7cf 100644 --- a/src/collective/taxonomy/exportimport.py +++ b/src/collective/taxonomy/exportimport.py @@ -92,26 +92,20 @@ def exportTaxonomy(context): for name in ['title', 'description', 'default_language']: value = getattr(taxonomy, name, None) if value: - if isinstance(value, six.string_types): - config.set('taxonomy', name, value.encode('utf-8')) - else: - config.set('taxonomy', name, value) + config.set('taxonomy', name, six.ensure_text(value)) for name in ['field_title', 'field_description', 'write_permission', 'taxonomy_fieldset']: value = getattr(behavior, name, None) if value: - if isinstance(value, six.string_types): - config.set('taxonomy', name, value.encode('utf-8')) - else: - config.set('taxonomy', name, value) + config.set('taxonomy', name, six.ensure_text(value)) for name in ['is_single_select', 'is_required']: value = getattr(behavior, name, None) if value: config.set('taxonomy', name, str(value).lower()) - filehandle = BytesIO() + filehandle = StringIO() config.write(filehandle) context.writeDataFile('taxonomies/' + short_name + '.cfg', filehandle.getvalue(), 'text/plain')