plone.app.multilingual/master: Merge pull request #290 from plone/field_safely_converted_to

GitHub <jenkins-z4DKO/[email protected]>
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: plone.app.multilingual
Branch: refs/heads/master
Date: 2017-07-19T17:08:45+02:00
Author: Jens W. Klein (jensens) <jk-jUMamYRpa/IasaSY4/nUZ7NldLUNz+W/@public.gmane.org>
Commit: https://github.com/plone/plone.app.multilingual/commit/de8d96f5b9139ef37bb5f9ee35ecdde476003911

Merge pull request #290 from plone/field_safely_converted_to_unicode

Safely convert field value to unicode

Files changed:
M CHANGES.rst
M src/plone/app/multilingual/dx/cloner.py

diff --git a/CHANGES.rst b/CHANGES.rst
index 2807bd2a..e1b5faef 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -23,7 +23,7 @@ Bug fixes:
 New features:
 
 - Rebuilt po files
-  [erral]  
+  [erral]
 
 - Rename ``media`` folder to a more generic name ``assets`` by default and
   add i18nize it to be localization aware
@@ -47,6 +47,10 @@ New features:
 
 Bug fixes:
 
+- Safely convert field value to unicode
+  [agitator, GerardRodes]
+
+
 - Add missing i18n:translate tags
   [erral]
 
diff --git a/src/plone/app/multilingual/dx/cloner.py b/src/plone/app/multilingual/dx/cloner.py
index aab13980..4c446c36 100644
--- a/src/plone/app/multilingual/dx/cloner.py
+++ b/src/plone/app/multilingual/dx/cloner.py
@@ -1,16 +1,18 @@
 # -*- coding: utf-8 -*-
 from plone.app.multilingual.dx.interfaces import ILanguageIndependentField
-from Products.CMFPlone.interfaces import ILanguage
 from plone.app.multilingual.interfaces import ILanguageIndependentFieldsManager
 from plone.app.multilingual.interfaces import ITranslationCloner
 from plone.app.multilingual.interfaces import ITranslationManager
 from plone.dexterity.utils import iterSchemata
+from Products.CMFPlone.interfaces import ILanguage
+from Products.CMFPlone.utils import safe_unicode
 from z3c.relationfield import RelationValue
 from z3c.relationfield.interfaces import IRelationList
 from z3c.relationfield.interfaces import IRelationValue
 from zope.component import getUtility
 from zope.component import queryAdapter
 from zope.interface import implementer
+
 import pkg_resources
 try:
     # pkg_resources.get_distribution('zope.initd')
@@ -74,7 +76,8 @@ def relation_copier(rel, lang=target_language, fun=self.copy_relation):
                         value = map(relation_copier, value or [])
 
                     doomed = True
-                    setattr(schema(translation), field_name, value)
+                    setattr(schema(translation),
+                            field_name, safe_unicode(value))
 
         # If at least one field has been copied over to the translation
         # we need to inform subscriber to trigger an ObjectModifiedEvent



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.