RelatedItemsFieldWidget error in migrated site (solved)

Plone = 5.0.6 (just migrated from 4.3.6)
plone.app.widgets = 2.0.7
plone.app.z3cform = 2.2.1

Actual Problem

I'm using a RelatedItemsFieldWidget on a custom content type

The RelatedItemsFieldWidget results are failing to load in Plone 5 when editing existing items. The widget itself loads, but when I click in the box, a dropdown displays showing only 'Loading failed', and in the console I see a 404 was returned from @@edit/++widget++form.widgets.related_issue/@@getSource.

If I add a new item, I am able to use the field. If I then save the new item and edit it, the field returns a 404 again.

Details

In the new Products.Poi (not released, on 3.0-development branch), there is a related_issue field using a RelatedItemsFieldWidget. This works fine in a new Plone 5 site with newly-installed Poi.

I am working to migrate a site from Plone 4 to Plone 5, which also updates Poi from 2.x to 3.0. This site had been using a custom version of Poi that had a related issues field (core Poi did not have this before 3.0). I don't have the actual relations getting migrated yet, but the widget still fails. I don't remember if it failed before I was attempting to migrate the field.

Old field:

OrderableReferenceField('relatedIssue',
        multiValued=1,
        relationship='related_issue',
        allowed_types=('PoiIssue'),
        widget=IssueReferenceWidget(
            label=('Related issue(s)'),
description='Link related issues')),

New field:

widget('related_issue',
       RelatedItemsFieldWidget,)
related_issue = RelationList(
    title=_(u'Poi_label_issue_related', default=u'Related Issue(s)'),
    description=_(u'Poi_help_issue_related',
                  default=u'Link related issues.'),
    value_type=RelationChoice(
        title=u"Related",
        source=tracker_issues,
    ),
    required=False
)

Other Info

When adding a new issue, I can access ++add++Issue/++widget++form.widgets.related_issue, and see the plain widget.

But when editing, issue/edit/++widget++form.widgets.related_issue returns a 404.

For reference: turned out this was an issue in our Poi code. What might be helpful information to others is how I debugged it:

  1. In the error log, I removed NotFound

  2. Hit the widget again, and saw this in the error log:

    Traceback (innermost last):
    Module ZPublisher.Publish, line 127, in publish
    Module ZPublisher.BaseRequest, line 523, in traverse
    Module ZPublisher.HTTPResponse, line 727, in debugError
    NotFound: Site Error

  3. Put a PDB in Zope2.ZPublisher.BaseRequest at line 522, inside the except, also set variable e for the error (except (KeyError, AttributeError, ztkNotFound) as e:)

  4. When I refreshed and got the pdb prompt, I was then able to type e to see what the actual error was that was happening.

2 Likes