I would like to use the collective.z3cform.datagridfield addon on a standalone form I'm writing on plone5.2 (python3), but I can't even get the sample code to run:
Here the code I used (imports are omitted) from README.rst
:
interfaces.py
class ITableRowSchema(interface.Interface):
one = schema.TextLine(title=u"One")
two = schema.TextLine(title=u"Two")
three = schema.TextLine(title=u"Three")
class IFormSchema(interface.Interface):
four = schema.TextLine(title=u"Four")
table = schema.List(title=u"Table",
value_type=DictRow(title=u"tablerow", schema=ITableRowSchema))
browser/editform.py
@component.adapter(IFormSchema)
class EditForm(form.EditForm):
fields = field.Fields(IFormSchema)
label=u"Demo Usage of DataGridField"
fields['table'].widgetFactory = DataGridFieldFactory
browser/configure.zcml
...
<browser:page
name="editform--example"
class=".editform.EditForm"
for="*"
permission="zope2.View"
/>
...
When I access the view through http://localhost:8080/mig/@@editform--example
I keep getting the following error:
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 155, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 337, in publish_module
Module ZPublisher.WSGIPublisher, line 255, in publish
Module ZPublisher.mapply, line 85, in mapply
Module ZPublisher.WSGIPublisher, line 61, in call_object
Module z3c.form.form, line 233, in __call__
Module z3c.form.form, line 226, in update
Module plone.z3cform.patch, line 20, in BaseForm_update
Module z3c.form.form, line 154, in update
Module z3c.form.form, line 136, in updateWidgets
Module z3c.form.field, line 243, in update
Module z3c.form.datamanager, line 102, in canWrite
Module z3c.form.datamanager, line 66, in adapted_context
TypeError: ('Could not adapt', <PloneSite at /mig>, <InterfaceClass my.formtest.interfaces.IFormSchema>)
What am I doing wrong?