[SOLVED] Issue with RelationWidget and plone.app.queryparser

Plone 5.1.6.
We have a portlet with a RelationChoice field defined as

            target_employee = RelationChoice(
            title=_(u'HUEmployee'),
            description=_(u'Please enter the name or PID of an employee'),
            required=False,
            source=CatalogSource(portal_type='HUEmployee'))

When we render the portlet and click on the "home" button of the widget that we expect to see the folder hierarchy in order to navigate through the site. However the nothing is shown "no results".

plone.app.queryparser.parseFormQuery() get this data:

{'_': u'1579856509074',
 'attributes': u'["UID","Title","portal_type","path","getURL","getIcon","is_folderish","review_state"]',
 'batch': u'{"page":1,"size":10}',
 'query': u'{"criteria":[{"i":"path","o":"plone.app.querystring.operation.string.path","v":"/spowi213/::1"}],"sort_on":"getObjPositionInParent","sort_order":"ascending"}'}

The context of the call is the navigation root /spowi213/de .

The query for path is transformed into (through plone.app.querystring.queryparser._pathByRoot()) into

{'depth': 1, 'query': [u'/spowi213/de/spowi213']}

The query=/spowi213/de/spowi213i s obviously wrong since it falsely includes the site ID into the path. The correct result would be query=/spowi213/de.

Is this an error in plone,.app.queryparser or is the relation widget sending an improper query?

The solution here is/was to specify pattern_options:

        target_employee = RelationChoice(
            title=_(u'HUEmployee'),
            description=_(u'Please enter the name or PID of an employee'),
            required=False,
            vocabulary='plone.app.vocabularies.Catalog',
        )
        directives.widget(
            'target_employee',
            RelatedItemsFieldWidget,
            pattern_options={
                'selectableTypes': ['HUEmployee'],
                'basePath': '/',
                'favorites': [],
            },
        )
1 Like

Plone Foundation Code of Conduct