plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
246 stars 187 forks source link

Dexterity Schema unaccessible after update to 5.1b4 #2093

Closed tomgross closed 6 years ago

tomgross commented 7 years ago

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

What I did:

I updated a Plone site from 5.1b3 to 5.1b4 pending. The site has PAM installed with three languages de (default), en, fr. The site did NOT use combinded languages.

What I expect to happen:

Schema editing in control panel works. http://localhost:8080/Plone/dexterity-types/Document/@@fields

What actually happened:

An error was raised:

Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.z3cform.layout, line 68, in __call__
  Module plone.z3cform.layout, line 47, in update
  Module plone.z3cform.fieldsets.extensible, line 65, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 141, in update
  Module z3c.form.group, line 52, in update
  Module z3c.form.group, line 48, in updateWidgets
  Module z3c.form.field, line 277, in update
  Module z3c.form.browser.select, line 51, in update
  Module z3c.form.browser.widget, line 171, in update
  Module z3c.form.widget, line 234, in update
  Module Products.CMFPlone.patches.z3c_form, line 47, in _wrapped
  Module z3c.form.widget, line 115, in update
  Module zope.schema._bootstrapfields, line 78, in __get__
  Module zope.schema._bootstrapfields, line 183, in validate
  Module zope.schema._field, line 338, in _validate
ConstraintNotSatisfied: ('en-us', 'language')

Also the combined language flag changed with the update. I reset it manually but the error persists.

What version of Plone/ Addons I am using:

Plone 5.1b4 with PAM

hvelarde commented 7 years ago

this is happening also in Plone 4.3.11 with latest plone.app.contenttypes 1.1.1 installed:

2017-07-05 10:44:15 ERROR Zope.SiteErrorLog 1499262255.680.314348439049 http://localhost:8080/Plone/news/++add++News%20Item
Traceback (innermost last):
  Module ZPublisher.Publish, line 138, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 48, in call_object
  Module plone.z3cform.layout, line 66, in __call__
  Module plone.z3cform.layout, line 50, in update
  Module plone.dexterity.browser.add, line 118, in update
  Module plone.z3cform.fieldsets.extensible, line 59, in update
  Module plone.z3cform.patch, line 30, in GroupForm_update
  Module z3c.form.group, line 141, in update
  Module z3c.form.group, line 52, in update
  Module z3c.form.group, line 48, in updateWidgets
  Module z3c.form.field, line 277, in update
  Module z3c.form.browser.select, line 51, in update
  Module z3c.form.browser.widget, line 171, in update
  Module z3c.form.widget, line 234, in update
  Module z3c.form.widget, line 115, in update
  Module zope.schema._bootstrapfields, line 78, in __get__
  Module zope.schema._bootstrapfields, line 182, in validate
  Module zope.schema._field, line 389, in _validate
ConstraintNotSatisfied: pt-br
thet commented 7 years ago

That might be related to: https://github.com/plone/plone.app.dexterity/pull/251

@hvelarde are you using plone.app.dexterity 2.4.4 instead 2.0.18?

The easiest fix would be to revert that change. I'm wondering where the language en-us comes from, in case of @tomgross problem.

/cc @jensens @mauritsvanrees opinions on how to fix this?

tomgross commented 7 years ago

I downgraded to plone.app.dextertiy 2.4.3 but the error still persists.

hvelarde commented 7 years ago

this is what I have:

$ grep dexterity bin/instance 
    '/home/hvelarde/.buildout/eggs/plone.dexterity-2.2.7-py2.7.egg',
    '/home/hvelarde/.buildout/eggs/plone.app.dexterity-2.0.18-py2.7.egg',
thet commented 7 years ago

@hvelarde @tomgross to be able to reproduce your problems, can you please provide me with the following info:

thet commented 7 years ago

@tomgross @hvelarde - just saw your comments regarding versions - looks like the errors are not related to my PRs:

Also, it's unlikely anyways, as they should not affect the schemaeditor...

agitator commented 7 years ago

Updated a 5.1b2 multilingual (de, fr, it, en) site to 5.1b4

http://localhost:8080/Plone/dexterity-types/Document/@@fields works for me

plone.dexterity-2.5.2-py2.7.egg plone.app.dexterity-2.4.4-py2.7.egg

tomgross commented 7 years ago

I have a suspect. We set the language programmatically. This was a string until Plone 5.1b3. With Plone 5.1b4 the script complained about an unicode issue for new sites. I'll try to change the language settings to unicode on our existing site and report.

tomgross commented 7 years ago

Yeah, this did the trick for me:

    language_tool = api.portal.get_tool(name='portal_languages')
    for lang in [u'de', u'en', u'fr']:
        language_tool.addSupportedLanguage(lang)

    portal = api.portal.get()
    ml_setup_tool = SetupMultilingualSite()
    ml_setup_tool.setupSite(portal)
tomgross commented 7 years ago

I'm unsure wheter this issue should be closed. Ideally an upgrade step takes care for the transition but setting the language programmatically is probably not a common use case.

thet commented 7 years ago

Sounds like an upgrade step among a note/warning in the incompatibilities section of the CMFPlone changelog is needed.

I'm curious what caused the problem. Must be some common package which Plone 4.3.x ( @hvelarde problem) and 5.1.x uses.

pbauer commented 7 years ago

I just has a related problem with 5.1b4. For me the issue was that the value for plone.available_languages was empty since since I was setting it wrong in my registry.xml. That was no issue before but now the value for 'language' in schemas gets validated against the vocabulary.

api.portal.get_registry_record('plone.available_languages') returned [] instead of ['de'] which it does in a newly created site.

My error was to set it using::

<record name="plone.available_languages" interface="Products.CMFPlone.interfaces.controlpanel.ILanguageSchema" field="available_languages">
  <value>['de']</value>
</record>

instead of

<record name="plone.available_languages" interface="Products.CMFPlone.interfaces.controlpanel.ILanguageSchema" field="available_languages">
  <value>
    <element>de</element>
  </value>
</record>
tomgross commented 6 years ago

I'm closing this now. The special cases for programmatically setting of languages and profile requirements are documented here for further reference.