Integration with the backend

Integration with the backend#

Integration with the Plone CMS is provided by the Plone API framework, namely plone.restapi and its lower-level plone.rest. For details, check the REST API documentation.

Some of the more interesting integration features that you can look up in the plone.restapi documentation include the following.

Endpoints

The equivalent of Plone "views", these are REST API endpoints that you can call from the frontend. The response should be in JSON format. You'll use these for any type of interaction with the backend.

Content expansions

Additional information that can be added to the main response. For example, when fetching "content" information, you may want to also include information about the author. You could write an expansion that automatically inserts that information if the HTTP GET parameter ?expand=author is present in the request. It is also possible to create expansion elements that will automatically insert their content in the response, without the need for the request parameter.

Block transformers

These are named subscribers that can be used to automatically change the information that is sent to the frontend for some of the blocks. They can also do the opposite, to process the information coming from the frontend on create or update operations, and change the way the block value is stored in the database. There are multiple use cases for this type of feature. For example to automatically convert incoming links in block values to resolveuid-based links, and to convert them back to absolute URLs when retrieving the block value from the frontend.

Search and indexing integration

By providing the right adapters, you can extract searchable text from blocks.

Client reducer content transforms

These transforms run in the client when the response from the backend is received. These are useful when you need to modify the response from the backend on-the-fly for amending the backend data, such as a data migration of any kind. You can register a utility that mutates the response at your convenience.

import { upgradeV20241023 } from './upgrades/upgradeV20241023';

config.registerUtility({
  name: 'upgradeV20241023',
  type: 'transform',
  dependencies: { reducer: 'content' },
  method: upgradeV20241023,
});

The type of the utility needs to be transform, and the dependencies set to {reducer: 'content'}.

Proxied backend routes#

Access to images and files are a special use case in Volto. Usually in plain HTML, src and href attributes resource calls cannot be wrapped in a JavaScript backend call. This is problematic when dealing with protected resources that need the user to be authenticated to access them. For this reason, these resources are rerouted through an internal route in the Node.js Express server and wrapped with the proper authentication headers.

These proxied backend routes are in place for accessing URLs containing @@downloads @@display-file, and @@images backend views. These are the backend BrowserViews routes that retrieve images and file resources. Thus the Node.js Express server takes care of proxying and enhancing them at the same time as the authentication headers.

Alternative backends#

Volto can also be used with other backend systems if they provide an API that is compatible with plone.restapi.

Nick is a headless CMS built with Node.js that supports Volto as a frontend.

Guillotina is a resource management system built with Python. It was inspired by Plone, using its same basic concepts, such as traversal, content types, and its permissions model.

There is also a Volto Node.js-based backend reference API implementation that demonstrates how other systems could also use Volto to display and create content through it.