Help? restapi custom serializer for specific field


For customizing a specific field instance, a named IFieldSerializer adapter can be registered. The name may either be the full dottedname of the field ( or the shortname of the field (exclude_from_nav).

I can't seem to get the named adapter to work to override this 'featured_image' field:

Removing the 'name' from the zcml works - I'm just lucky I have only one IRelationChoice in my schema.


The schema for 'IStory': ( )

class IStory(model.Schema):
    # snip other fields
    featured_image = RelationChoice(
        title=_(u'Featured Image'),
       # snip stuff


  <adapter factory=".serializer.FeaturedImageField"


  <adapter factory=".serializer.FeaturedImageField"
 /> - let's just catch it with a debug.

from rfasite.content.content.story import IStory

@adapter(IRelationChoice,IStory, Interface)
class FeaturedImageField(DefaultFieldSerializer):

    def __call__(self):
        import pdb; pdb.set_trace()

possible solution, specify your request with a Marker Interface ?

@adapter(IRelationChoice, IDexterityContent, IMigrationMarker)

:slight_smile: never trust docs and double-check with the source code, specially when something doesn't work.

I don't see any name passed to the getMultiAdapter call, so you shouldn't register the field serializer adapter with a name.

I saw that same code. But wasn’t sure.

I didn’t trace to it like a good boy, but only assumed it was the code that was run.

That’s why I came here first before going to github and filling an issue.

In fact, I didn’t search open issues either.