I have register a custom adpater
<adapter factory=".serializer.CustomSerializeToJson" />
the adpater should add the fullname of creator to the JSON:
@adapter(IDexterityContent, IMyAddOnLayer)
@implementer(ISerializeToJson)
class CustomSerializeToJson(SerializeToJson):
def __call__(self, version=None, include_items=True):
result = super(CustomSerializeToJson, self).__call__(
version=version, include_items=include_items
)
result["creatornames"] = []
for creator in result["creators"]:
fullname = creator_name(creator)
result["creatornames"].append(fullname)
return result
The Item itself is a folderish News Item:
# -*- coding: utf-8 -*-
from plone.app.contenttypes.interfaces import INewsItem as INewsItemOriginal
from plone.dexterity.content import Container
from zope.interface import implementer
class INewsItem(INewsItemOriginal):
"""Folderish News"""
@implementer(INewsItem)
class NewsItem(Container):
"""Convenience subclass for ``News Item`` portal type"""
The adapter doesn't work for IDexterityContent
, but for IDexterityContainer
. I would use this adapter for Items and Containers both. I wonder me because plone.dexterity subclassing Item and Container from IDexterityContent.
class IDexterityItem(IDexterityContent):
"""Marker interface applied to dexterity-managed non-folderish objects"""
class IDexterityContainer(IDexterityContent):
"""Marker interface applied to dexterity-managed folderish objects"""
Any hints?