Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scales create NamedBlobImage with wrong contentType field #38

Closed
rodfersou opened this issue Dec 22, 2016 · 14 comments
Closed

Scales create NamedBlobImage with wrong contentType field #38

rodfersou opened this issue Dec 22, 2016 · 14 comments

Comments

@rodfersou
Copy link
Member

NamedBlobImage contentType field should be string not unicode.

But when the image is scaled, it becomes unicode, what creates validation issues in image fields 1, 2.

This bug was introduced in this refactoring.

@hvelarde
Copy link
Member

I can confirm this issue and I can also confirm fixing it is not that easy as getting rid of the u'' as all scales in the portal created with the wrong content type will have wrong information.

we need to write an upgrade step or to find out a good place for data casting.

@plone/framework-team ideas?

@rodfersou
Copy link
Member Author

rodfersou commented Dec 22, 2016

maybe we can add a cast before raise the validation exception.. that's the unique place where we have problems.. the image is showed without problem.

@rodfersou
Copy link
Member Author

A little bit more information about the original exception:

/home/rodfersou/.anyenv/envs/pyenv/versions/2.7.12/envs/collective.cover/lib/python2.7/site-packages/IPython/core/debugger.py:238: DeprecationWarning: The `color_scheme` argument is deprecated since version 5.1
  DeprecationWarning)
> /home/rodfersou/.projects/cache/eggs/zope.schema-4.2.2-py2.7.egg/zope/schema/_bootstrapfields.py(210)_validate()
    208         if self._type is not None and not isinstance(value, self._type):
    209             import debug
--> 210             raise WrongType(value, self._type, self.__name__)
    211 
    212         if not self.constraint(value):

ipdb> value
u'image/jpeg'
ipdb> self._type
<type 'str'>
ipdb> self
<zope.schema._field.BytesLine object at 0x7f0b568b7c50>
ipdb> self.__name__
'contentType'

@gforcada
Copy link
Member

a try..except with a note could be a good idea, with a comment pointing to this issue for example.

@rodfersou
Copy link
Member Author

@gforcada where would be the right place for this try..except?

@gforcada
Copy link
Member

gforcada commented Jan 2, 2017

@rodfersou you were pointing to a single place where this could be wrapped in a try..except already some comments above: #38 (comment)

@rodfersou
Copy link
Member Author

@gforcada I'm not sure if the place I pointed is the right one, since the exception is too generic for many cases.

maybe add a IF statement to don't raise the exception in one specific condition would work out.

@hvelarde
Copy link
Member

hvelarde commented Jan 3, 2017

@thet comments, please!

@thet
Copy link
Member

thet commented Jan 3, 2017

@hvelarde @rodfersou an upgrade step to fix the wrong contentType values + a plone.namedfile fix to not turn the contentType to unicode would be it, IMO.
@hvelarde anything else you need me to comment on?

@thet
Copy link
Member

thet commented Jan 3, 2017

A try..except in zope.schema with a cast on except is not an option, if understood the discussion above correctly.

@rodfersou
Copy link
Member Author

@thet can you guide me on how this upgrade step would be? are there any way to search for every configlet with image widget where this exception happen?

@hvelarde
Copy link
Member

hvelarde commented Jan 3, 2017

@rodfersou keep it simple: search for images and scales only; my only concern is about the upgrade step memory consumption.

@thet
Copy link
Member

thet commented Jan 3, 2017 via email

@thet
Copy link
Member

thet commented Apr 25, 2017

Should be fixed via:
#41
and
#45

@thet thet closed this as completed Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants