plone.restapi icon indicating copy to clipboard operation
plone.restapi copied to clipboard

Using CatalogSource sources

Open tiberiuichim opened this issue 3 years ago • 2 comments

The @sources endpoint is registered now for IContentish, which is not provided by Plone root.

A field such as

partner= RelationChoice(source=CatalogSource(portal_type='Partner'))

Is serialized like:

    "partner": {
      "behavior": "IHasPartner", 
      "description": "", 
      "factory": "Relation Choice", 
      "title": "Partner", 
      "type": "string", 
      "vocabulary": {
        "@id": "http://localhost:3000/@sources/partner"
      }
    },

Notice the @source endpoint is rooted in the Plone root.

tiberiuichim avatar Aug 08 '21 06:08 tiberiuichim

It seems like @source bails out early if there's no field found. https://github.com/plone/plone.restapi/blob/34dc327285efe85ac7ee2bac73905f7352818bc8/src/plone/restapi/services/sources/get.py#L35

I think it should take into consideration the CatalogSource use case, which is a context-less source.

tiberiuichim avatar Aug 08 '21 06:08 tiberiuichim

@tiberiuichim as long as we do not have Plone 6 with the Dx-siteroot PLIP merged, we can register the @sources endpoint for the Plone root. This is what we did for other endpoints as well.

tisto avatar Aug 08 '21 08:08 tisto