IFromUnicode exception

Hi everyone,

We have a use case that we need to add a new textarea field as a behavior.

To create this behavior I wrote this code:

# coding: utf-8
from example.portal import _
from plone.autoform import directives as form
from plone.autoform.interfaces import IFormFieldProvider
from plone.supermodel import model
from zope import schema
from zope.interface import provider

class IExample(model.Schema):

    """Behavior example."""


    external_related_items = schema.Tuple(

I used similar code in other form, so I didn't expect this exeption:

2017-09-18 11:56:48 ERROR Zope.SiteErrorLog 1505746608.630.713578418328 http://localhost:8080/Plone/videos/evolution-of-usain-bolts-races-2004-2794-2017/@@edit
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 z3c.form.form, line 233, in __call__
  Module plone.dexterity.browser.edit, line 64, 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.textarea, line 37, in update
  Module z3c.form.browser.widget, line 171, in update
  Module Products.CMFPlone.patches.z3c_form, line 46, in _wrapped
  Module z3c.form.widget, line 131, in update
  Module zope.component.hookable, line 33, in __call__
  Module zope.component.hooks, line 104, in adapter_hook
  Module z3c.form.converter, line 86, in FieldWidgetDataConverter
  Module zope.component._api, line 120, in queryMultiAdapter
  Module zope.component.registry, line 238, in queryMultiAdapter
  Module zope.interface.adapter, line 532, in queryMultiAdapter
  Module z3c.form.converter, line 78, in __init__
TypeError: Field ``example`` of type ``Tuple`` must provide ``IFromUnicode``.

Do someone know something about this exception?

just to be clear: the use case is not to add a textarea, but a list of external related items: each line in the textarea is meant to store a string like Title| http://example.org/ so we can process that later to create a list ok <a> tags pointing to those external items.

I found that the problem was caused by this code:


changed with:

form.widget('example', cols=25, rows=10)

and now is working fine

I notice you set a default. Try removing that and see what happens.
TypeError: Field example of type **Tuple** must provide IFromUnicode

Especially when looking at https://github.com/zopefoundation/z3c.form/blob/master/src/z3c/form/widget.py#L114 which sets the value to the default value (a tuple).

Not sure what could be default value. Maybe something implementing ITuple or IList ?

I was bitten by the same exception in other context and found that I was missing to implement this adapter:

1 Like