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

Can't edit basic tile with Dexterity-based content types #637

Closed
hvelarde opened this issue Jul 21, 2016 · 17 comments · Fixed by #694
Closed

Can't edit basic tile with Dexterity-based content types #637

hvelarde opened this issue Jul 21, 2016 · 17 comments · Fixed by #694

Comments

@hvelarde
Copy link
Member

hvelarde commented Jul 21, 2016

Plone 4.3.10 with plone.app.contenttypes 1.1.1 installed:

  • upload an Image or create a News Item with an image
  • drop the item in a basic tile
  • edit the tile
  • save it

the following validation error is shown (Wrong contained type):

selection_073

this was not happening before with Plone 4.3.9.

@hvelarde
Copy link
Member Author

@jensens @thet any hints?

@hvelarde hvelarde added the bug label Jul 21, 2016
hvelarde added a commit that referenced this issue Jul 21, 2016
@jensens
Copy link
Member

jensens commented Jul 21, 2016

@hvelarde sorry, I have no clue what's going on there.

@davilima6
Copy link
Contributor

@hvelarde: no traceback and nothing else in the console?

@hvelarde
Copy link
Member Author

@davilima6 nothing; seems some invariant or validator in the image widget.

@rodfersou
Copy link
Member

This validation looks to be into zope.schema._field.py file

@hvelarde
Copy link
Member Author

hvelarde commented Sep 5, 2016

I found the problem but I have no idea how to fix it: the value of the contentType property of the NamedBlobImage field is unicode instead of str:

> /home/hvelarde/.buildout/eggs/zope.schema-4.2.2-py2.7.egg/zope/schema/_field.py(586)_validate()
-> raise WrongContainedType(errors, self.__name__)
(Pdb) errors
[WrongType(u'image/jpeg', <type 'str'>, 'contentType')]
(Pdb) self.schema
<InterfaceClass plone.namedfile.interfaces.INamedBlobImage>
(Pdb) value
<plone.namedfile.file.NamedBlobImage object at 0x7f48ec341848>
(Pdb) value.contentType
u'image/jpeg'
(Pdb) type(value.contentType)
<type 'unicode'>

I have no idea of what's the cause of this bug.

@idgserpro can you confirm if this happens on the IDGB project, please?

@hvelarde
Copy link
Member Author

hvelarde commented Sep 5, 2016

according to @datakurre Dexterity and z3c.form converts all form data into unicode so maybe that is causing this issue.

we need to check if this fixes it: https://github.com/plone/plone.app.tiles/pull/10/files

@rodfersou
Copy link
Member

@rodfersou
Copy link
Member

@hvelarde @datakurre the fixes done at p.a.tiles raises an exception with c.cover tiles:

2016-12-22 11:52:05 ERROR Zope.SiteErrorLog 1482414725.910.636643873446 http://localhost:8080/Plone/capa/@@updatetilecontent
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module Products.PDBDebugMode.runcall, line 70, in pdb_runcall
  Module ZPublisher.Publish, line 48, in call_object
  Module collective.cover.browser.compose, line 57, in __call__
  Module collective.cover.browser.compose, line 52, in render
  Module collective.cover.tiles.basic, line 122, in populate_with_object
  Module z3c.form.form, line 37, in applyChanges
AttributeError: 'BasicTile' object has no attribute 'fields'
/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/z3c.form-3.2.9-py2.7.egg/z3c/form/form.py(37)applyChanges()
     35 def applyChanges(form, content, data):
     36     changes = {}
---> 37     for name, field in form.fields.items():
     38         # If the field is not in the data, then go on to the next one
     39         try:

@rodfersou
Copy link
Member

at my PR I just convert back image.contentType to string

@rodfersou
Copy link
Member

it looks like the bug was introduced in this commit by @thet

plone/plone.namedfile@33df023#diff-03f29bbadcdf640341c9061de5a07dccR299

When we scale the image, contentType attribute of NamedBlobImage object becomes unicode when it should be str

@hvelarde
Copy link
Member Author

hvelarde commented Dec 22, 2016

@rodfersou I just tested and that's not the code causing the issue; maybe we have to look in plone.formwidget.namedfile also; anyway, what you found has to be fixed.

@rodfersou
Copy link
Member

how did you test it? here it works

@datakurre
Copy link
Contributor

@rodfersou Great work!

@jensens
Copy link
Member

jensens commented Dec 22, 2016

@rodfersou bug hunting at its best!

@hvelarde
Copy link
Member Author

wow, I tested again and you were totally right; the problem was I was testing with an image created prior to the patch... that means now we have a huge issue: all scales in the portal must have to be checked using an upgrade step because the contentType attribute will be unicode and we'll need to update them to be str.

@thet
Copy link
Member

thet commented Apr 25, 2017

Should be fixed via:
plone/plone.namedfile#41
and
plone/plone.namedfile#45

@hvelarde if an upgrade step is really needed, talk to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants