Products.CMFPlone/cssmin_relacement: fix problem when passing a unicode string, error is in OFS.I

Alexander Loechel <jenkins-z4DKO/[email protected]>
Newsgroups gmane.comp.web.zope.plone.cvs
Message-ID <[email protected]>
Repository: Products.CMFPlone
Branch: refs/heads/cssmin_relacement
Date: 2017-07-20T00:06:58+02:00
Author: Alexander Loechel (loechel) <[email protected]>
Commit: https://github.com/plone/Products.CMFPlone/commit/0b49cdc6611f32497049dc152357b28418b9365d

fix problem when passing a unicode string, error is in OFS.Image, as str is only allowed, which might make sense for Python 3

Files changed:
M Products/CMFPlone/resources/browser/cook.py

diff --git a/Products/CMFPlone/resources/browser/cook.py b/Products/CMFPlone/resources/browser/cook.py
index a06cec4ac..7ddbb6ab7 100644
--- a/Products/CMFPlone/resources/browser/cook.py
+++ b/Products/CMFPlone/resources/browser/cook.py
@@ -148,6 +148,8 @@ def _write_resource(resource_path, cooked_string):
         resource_name, resource_filepath = resource_path.split('/', 1)
         if resource_name not in container:
             container.makeDirectory(resource_name)
+        if not isinstance(cooked_string, str):  # handle Error of OFS.Image
+            cooked_string = cooked_string.encode('ascii', errors='ignore')
         try:
             folder = container[resource_name]
             fi = StringIO(cooked_string)



------------------------------------------------------------------------------
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.