Hi all, first a bit of background.
I have the form below in Plone 5.0.10 which "almost works" - that is, only the first row of values in the nested DatagridField (article and quantity) are being saved. I found some hints that this is due to a buggy converter in the old version of collective.z3cform.datagridfield. In the Plone6 version this seems to have been fixed (thanks @petschki).
So, I decided to use Plone6 for my app, and stumbled on an InvalidVocabularyError in zope.schema.field for the same field... (Traceback below, edit: updated for Plone 6.0-latest).
The field works if I insert it in the main schema (bottom image)
I have read these two posts:
What am I doing wrong?
Plone 5.0.10
Plone 6
Field in the main schema works...
(Note: I am using a source binder ItalianCitiesSourceBinder that calls a simplified vocabulary for testing here)
Traceback:
2023-05-24 12:45:15,936 ERROR [Zope.SiteErrorLog:17][waitress-0] InvalidVocabularyError: http://localhost:8888/Plone/api/edi-order
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 181, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 390, in publish_module
Module ZPublisher.WSGIPublisher, line 285, in publish
Module ZPublisher.mapply, line 85, in mapply
Module Products.PDBDebugMode.wsgi_runcall, line 60, in pdb_runcall
Module Shared.DC.Scripts.Bindings, line 333, in __call__
Module Shared.DC.Scripts.Bindings, line 370, in _bindAndExec
Module Products.PythonScripts.PythonScript, line 338, in _exec
Module script, line 16, in edi-order
- <PythonScript at /Plone/api/edi-order>
- Line 16
Module z3c.form.form, line 233, in __call__
Module pnz.erpediem.client.browser.create_edi_order, line 345, in update
Module plone.z3cform.fieldsets.extensible, line 62, in update
Module plone.z3cform.patch, line 31, in GroupForm_update
Module z3c.form.group, line 132, in update
Module z3c.form.form, line 136, in updateWidgets
Module z3c.form.field, line 274, in update
Module z3c.form.browser.multi, line 63, in update
Module z3c.form.browser.widget, line 171, in update
Module z3c.form.widget, line 509, in update
Module Products.CMFPlone.patches.z3c_form, line 46, in _wrapped
Module z3c.form.widget, line 132, in update
Module z3c.form.widget, line 504, in value
Module collective.z3cform.datagridfield.datagridfield, line 154, in updateWidgets
Module collective.z3cform.datagridfield.datagridfield, line 126, in getWidget
Module z3c.form.browser.widget, line 171, in update
Module z3c.form.object, line 297, in update
Module collective.z3cform.datagridfield.datagridfield, line 267, in updateWidgets
Module z3c.form.object, line 222, in updateWidgets
Module z3c.form.object, line 216, in setupWidgets
Module z3c.form.field, line 274, in update
Module z3c.form.browser.multi, line 63, in update
Module z3c.form.browser.widget, line 171, in update
Module z3c.form.widget, line 509, in update
Module Products.CMFPlone.patches.z3c_form, line 46, in _wrapped
Module z3c.form.widget, line 132, in update
Module z3c.form.widget, line 504, in value
Module collective.z3cform.datagridfield.datagridfield, line 148, in updateWidgets
Module z3c.form.widget, line 445, in updateWidgets
Module collective.z3cform.datagridfield.datagridfield, line 126, in getWidget
Module z3c.form.browser.widget, line 171, in update
Module z3c.form.object, line 297, in update
Module collective.z3cform.datagridfield.datagridfield, line 267, in updateWidgets
Module z3c.form.object, line 222, in updateWidgets
Module z3c.form.object, line 216, in setupWidgets
Module z3c.form.field, line 274, 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 233, in update
Module z3c.form.widget, line 225, in updateTerms
Module zope.component._api, line 102, in getMultiAdapter
Module zope.component._api, line 116, in queryMultiAdapter
Module zope.interface.registry, line 364, in queryMultiAdapter
Module zope.interface.adapter, line 844, in queryMultiAdapter
Module z3c.form.term, line 108, in ChoiceTerms
Module zope.schema._field, line 458, in bind
Module zope.schema._field, line 448, in _resolve_vocabulary
zope.schema._field.InvalidVocabularyError: Invalid vocabulary <pnz.erpediem.core.vocabularies.edifact.sources.ItalianCitiesSourceBinder object at 0x7f59c87de040>
[55] > /usr/local/Plone6/lib/python3.8/site-packages/zope/schema/_field.py(448)_resolve_vocabulary()
-> raise InvalidVocabularyError(vocabulary).with_field_and_value(
(Pdb++)
(Pdb++) self
<zope.schema._field.Choice object at 0x7f1a9051d070 pnz.erpediem.client.browser.create_edi_order.IEDIOrderItemsRowSchema.order_item_article>
(Pdb++) self.source
<pnz.erpediem.core.vocabularies.edifact.sources.ItalianCitiesSourceBinder object at 0x7f1a7fed4e50>
(Pdb++) self.source(self.context).getTerm('bologna')
<zope.schema.vocabulary.SimpleTerm object at 0x7f1a81aaca90>
(Pdb++) self.source(self.context).getTerm('bologna')
<zope.schema.vocabulary.SimpleTerm object at 0x7f1a81aacbb0>
(Pdb++) self.source(self.context).getTerm('bologna').title
'Bologna'
My field:
order_item_article = schema.Choice(
title = _(
'order_item_article_title',
default=u'Article'
),
required = True,
#source = EDIOrderItemsSourceBinder(),
source = ItalianCitiesSourceBinder(),
default = '--NOVALUE--'
)
directives.widget(
'order_item_article',
SelectFieldWidget,
allowNewItems = False,
)