Error Saving registry fields

Hey Google, Index this string: "AttributeError: 'InterfaceConstrainedProperty' object has no attribute 'bind'"

This happens after following the instructions creating a new schema.List field on a new configuration form. Using these docs: Site setup and configuration — Plone Documentation v5.2

Then magically resolves itself before I can really investigate the edge case.

something simple like this:

   list_field_voc_unconstrained = schema.List(
        title=u'List field with values from vocabulary but not constrained to them.',
        value_type=schema.TextLine(),
        required=False,
        missing_value=[],
        )

It's not reliably repeatable. I installed the code on another instance, imported registry.xml to create the new key, and it ran perfectly; it saved the form data in the registry.

Today, I went to dig deeper (zope.schema._field will 'clone' the field and fail on cloning the value_type) and it magically began working. I hate it when things fix themselves.

The only hint I have is that MAYBE changing the value type on the schema while there is something already in the registry with a different value type might break something. But I'm unsure. I also ran the schema without a value type at first, realized my error, added it, and tried again. This may have aggravated the error.

I know that it ran on a clean installation - after importing registry.xml
I have a hint that it can be resolved by deleting the registry key from the debug console:

from zope.component import getUtility
from plone.registry.interfaces import IRegistry

registry = getUtility(IRegistry)
del registry.records['my.registry.key']
transaction.commit()

You get this, as expected:
KeyError: 'Interface 'my.product.IConfig' defines a field 'stuff', for which there is no record.'
and re-importing registry.xml to add it back.

Anyone with some hints and experience with this issue, please comment.

Plone 5.2.4 (5212)
CMF 2.5.0
Zope 4.5.5
Python 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0]
PIL 6.2.2 (Pillow)
WSGI: On
Server: waitress 1.4.4
zope.schema-6.0.0-py3.8.egg

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 371, in publish_module
  Module ZPublisher.WSGIPublisher, line 266, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module Products.PDBDebugMode.wsgi_runcall, line 60, in pdb_runcall
  Module plone.z3cform.layout, line 63, 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 145, in update
  Module plone.app.z3cform.csrf, line 22, in execute
  Module z3c.form.action, line 98, in execute
  Module z3c.form.button, line 315, in __call__
  Module z3c.form.button, line 170, in __call__
  Module plone.app.registry.browser.controlpanel, line 63, in handleSave
  Module z3c.form.group, line 114, in applyChanges
  Module z3c.form.form, line 51, in applyChanges
  Module z3c.form.datamanager, line 91, in set
  Module plone.registry.recordsproxy, line 60, in __setattr__
  Module plone.registry.registry, line 51, in __setitem__
  Module plone.registry.record, line 80, in _set_value
  Module zope.schema._field, line 886, in bind
  Module zope.schema._field, line 768, in bind
AttributeError: 'InterfaceConstrainedProperty' object has no attribute 'bind'

Maybe a missing paramter in the definition of your field for the value_type? schema.TextLine(title="...")

It's possible.

Evidence points to no. The schema I was using did not have a title in the value_type. I was getting the error, and when the branch was deployed into a testing environment, the error did not occur.

My theory is I created the schema without a value_type at all, started up plone, and visited the form. That's what broke it. Adding the value_type and restarting plone doesn't fix it. I need to confirm the steps, tho.


Create a schema:

class TestSchema(Interface):
test = schema.List(
        title=u'Create a list field and forget to set value_type',
        required=False,
        )

And use it like this: Site setup and configuration — Plone Documentation v5.2.

Get passed the KeyError by importing your registry.xml.

Then, go back and fix the schema - add a value_type (as you should).

I think you get stuck then.

I remember having similar issues once with a registry field for which I changed the type and then ran into issues on an existing instance of the site where the 'old' type was still stored in the registry and it kept complaining about Unicode. Edge case indeed.

Plone Foundation Code of Conduct