Relations KeyError

I have a sample content type with a Relation List field defined as follows:

from plone.directives import dexterity, form
from zope import schema
from plone.autoform.interfaces import IFormFieldProvider
from zope.interface import alsoProvides
from plone.namedfile.interfaces import IImageScaleTraversable
from z3c.relationfield.schema import RelationList, RelationChoice
from plone.supermodel import model
from sample.system import MessageFactory as _
from plone.formwidget.contenttree import UUIDSourceBinder

class IBuilding(model.Schema, IImageScaleTraversable):
    """
    Building form
    """
   parking_slot = RelationList(
        title = _(u'Parking Slots'),
        default=[],
        value_type=RelationChoice(
            title=_(u"Parking Slot"),
            source=UUIDSourceBinder(portal_type='sample.system.parkingslot')
        ),
        required=False,
    )

    pass

alsoProvides(IBuilding, IFormFieldProvider)

The above renders an add form and the widget works. However, when I save the form, I get the following error:

2017-03-17 08:38:55 ERROR Zope.SiteErrorLog 1489711135.670.090679112371 http://localhost:8080/Plone/sample/buildings/++add++sample.system.building
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 145, in update
Module plone.app.z3cform.csrf, line 21, 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.dexterity.browser.add, line 101, in handleAdd
Module z3c.form.form, line 263, in createAndAdd
Module plone.dexterity.browser.add, line 66, in create
Module z3c.form.form, line 51, in applyChanges
Module plone.app.relationfield.widget, line 128, in set
Module five.intid.intid, line 41, in getId
Module zope.intid, line 84, in getId
KeyError: '09dcba306e33464eb589f2a1a087a716'

I am running a Plone 4.3.11 buildout with the following module versions:

plone.formwidget.contenttree = 1.0.15
plone.app.relationfield = 1.2
five.intid = 1.0.3
z3c.relationfield = 0.6.3
zc.relation = 1.0

If I use plone.formwidget.contenttree.ObjPathSourceBinder, the form saves and the relationship is established. However, I want to have the UUID saved instead of the path.

I would appreciate any pointers from the community.

Thank you.

I usually use ObjPathSourceBinder for RelationChoice fields. And maybe use
the object_provides instead of portal_type.

Thank you for your reply. I have learned since that using ObjPathSourceBinder for my case is okey. From what I have read, relation fields do not really store the path or uuid but instead use IntIds. So the source or vocabulary is just used to find the selected objects, create Intids, and save these on the referring object.

Holden

that means you have a broken relation; try rebuilding the catalog of content references (reference_catalog).

I did check reference_catalog and it was empty even if I have already related some items. Isn't reference_catalog only used by AT? I am using p.a.contenttypes. I am now able to establish relations via ObjPathSourceBinder. The reference_catalog remains empty.

Had the same problem, fresh site. As a workaround, switched to ObjPathSourceBinder. Was not able to figure out how to construct the binder query with a object_provides constraint, either - just passing it as a kwarg did not work either.