collective.multiworkflow.restapi.serializer#

collective.multiworkflow.restapi.serializer.dxcontent#

Add workflow_states to plone.restapi's content serialization.

The key sits beside review_state in the payload of every Dexterity object, carrying the object's state in every workflow of its chain, formatted as the workflow_states catalog index holds it.

The patch wraps SerializeToJson.__call__ on the class itself, rather than binding a subclass in its place. SerializeFolderToJson, SerializeCollectionToJson and any serializer an add-on derives from them reach it through super().__call__, so they all carry the key. And because plone.restapi's ZCML registers the very class that was patched, the order in which the two packages are configured does not matter.

A subclass overriding __call__ without calling super() does not carry the key. Nothing short of patching that subclass as well could change that.

The patch is applied when collective.multiworkflow.restapi.serializer is imported, which including its ZCML does.

collective.multiworkflow.restapi.serializer.dxcontent.apply_patch() → None[source]#

Wrap SerializeToJson.__call__ so its payload carries workflow_states.

The original method stays reachable as __wrapped__, which is what lets the spike test assert that upstream still lacks the key.

collective.multiworkflow.restapi.serializer.summary#

Summary serializer metadata for listings.

Adds the workflow_states catalog column to every ISerializeToJsonSummary payload, so a listing can show each item's state in every workflow of its chain without one request per item.

class collective.multiworkflow.restapi.serializer.summary.JSONSummarySerializerMetadata[source]#

Additional metadata to be exposed on listings.

default_metadata_fields() → set[str][source]#

Name the catalog columns to add to every summary.

Returns:

The set of extra field names.