Managers#
Each PloneClient has one manager per group of plone.restapi services, as an attribute.
Attributes and services#
Attribute |
Class |
Services |
|---|---|---|
|
content CRUD, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file and image fields, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Item references#
Every method that takes an item accepts any of these forms.
Form |
Example |
|---|---|
Path from the site root |
|
URL inside the site |
|
UID reference |
|
|
|
A UID reference costs one extra @search request.
A URL outside the site raises ValueError.
Block types#
client.block_types asks the @blocks-schema service of the Volto server, which lists the blocks a site offers with their documentation, data schema, and variations.
Volto serves it, not plone.restapi, so the request goes to the client’s frontend_url, without ++api++, and with a Bearer token.
A client that uses basic authentication gets the token from @login once.
When the site cannot answer, the manager describes Volto’s core blocks instead, from documentation that ships with plone-client.
Its answer then has "source": "builtin", a warning that says why, and no schema.
Situation |
Answer |
|---|---|
The service answers |
The site’s own answer, with |
|
Builtin. |
|
Builtin. |
|
Builtin. |
The client is anonymous, and the service answers |
Builtin. |
The service refuses the token with |
|
The service answers |
|
A builtin answer for a block that is not a core block |
The core blocks are slate, title, description, image, teaser, listing, gridBlock, search, video, maps, html, toc, and detachedSlate.
Their documentation comes from Volto, under the MIT license.
Classes#
Base class of the managers.
- class plone_client.managers.base.BaseManager(client)[source]#
Bases:
objectGroup the calls to one area of
plone.restapi.A manager holds no state of its own: every call goes through the
PloneClientit belongs to.- Parameters:
client (PloneClient) – The client.
Content: read, create, update, delete, copy, move, order and lock items.
- class plone_client.managers.content.ContentManager(client)[source]#
Bases:
BaseManagerContent items, through the content endpoints of
plone.restapi.Every method takes the path of an item, or its URL as found in
@id.- Parameters:
client (PloneClient)
- get(ref='/', *, expand=None, fullobjects=False, include_items=None, version=None, **params)[source]#
Serialization of an item.
- Parameters:
ref (str) – Path or URL of the item; also
uid:<UID>.expand (str | Iterable[str] | None) – Components to expand inline (
breadcrumbs,navigation,translations…).fullobjects (bool) – Serialize the contained items in full.
include_items (bool | None) –
Falseleaves the contained items out.version (str | int | None) – Version of the item to return, from
@history.params (Any) – Other query parameters.
- Returns:
The item.
- Return type:
- find_by_uid(uid)[source]#
Catalog entry of the item with a UID.
- Parameters:
uid (str) – The UID.
- Returns:
The search result, with
@id,@typeandtitle.- Raises:
PloneNotFoundError – If no item has this UID.
- Return type:
- resolve(ref)[source]#
Site path for a reference.
Plain paths and URLs are only normalized.
uid:<UID>andresolveuidlinks are looked up in the catalog.- Parameters:
ref (str) – Path, URL,
uid:<UID>orresolveuidlink.- Returns:
The site path.
- Raises:
PloneNotFoundError – If the UID is not found.
- Return type:
- children(ref='/', *, portal_type=None, metadata_fields=None, limit=None, b_size=100)[source]#
Items directly inside a folder, in the folder’s order.
Uses
@searchon the folder, so each item is a catalog entry rather than a full serialization.- Parameters:
ref (str) – Path or URL of the folder.
portal_type (str | Iterable[str] | None) – Only items of these types.
metadata_fields (str | Iterable[str] | None) – Extra catalog metadata to return (
_allfor every column).limit (int | None) – Stop after this many items.
b_size (int) – Items fetched per request.
- Returns:
Each item.
- Return type:
- create(parent, portal_type, data=None, **fields)[source]#
Create an item inside a folder.
Read the
@idof the result rather than assuming it: Plone may change the id that was asked for.- Parameters:
- Returns:
The new item.
- Raises:
PloneBadRequestError – If the id is in use, the type is not allowed in the folder, or a field is invalid.
- Return type:
- update(ref, data=None, *, lock_token=None, representation=True, **fields)[source]#
Change fields of an item (
PATCH).- Parameters:
- Returns:
The changed item, or
Nonewithrepresentation=False.- Return type:
- delete(ref)[source]#
Delete an item.
- Parameters:
ref (str) – Path or URL of the item.
- Raises:
PloneBadRequestError – If link integrity forbids the deletion.
- Return type:
None
- order(folder, obj_id, delta, *, subset_ids=None)[source]#
Move an item within its folder.
- Parameters:
folder (str) – Path or URL of the folder.
obj_id (str) – Id of the item to move.
delta (int | Literal['top', 'bottom']) – Positions to move (negative moves up),
toporbottom.subset_ids (Iterable[str] | None) – Ids of the items the client knows about, in their current order; the site refuses the change if they are out of date.
- Return type:
None
Search: the @search catalog query and @querystring-search.
- class plone_client.managers.search.SearchManager(client)[source]#
Bases:
BaseManagerCatalog queries through
@search.Searching on a folder restricts the results to that folder, which works the same with and without virtual hosting. That is why
pathhere is the folder to search in, not apathindex query.- Parameters:
client (PloneClient)
- search(path='/', *, query=None, portal_type=None, review_state=None, text=None, depth=None, sort_on=None, sort_order=None, metadata_fields=None, fullobjects=False, b_size=None, b_start=None, **indexes)[source]#
One page of results.
- Parameters:
path (str) – Folder to search in; the site root by default.
query (Mapping[str, Any] | None) – Catalog query as a mapping, for index names that are not valid keyword arguments; nested options are flattened (
{"created": {"query": "2026-01-01", "range": "min"}}).review_state (str | Iterable[str] | None) – Workflow states.
text (str | None) – Full-text search (
SearchableText).depth (int | None) – Levels below
path:0is the folder itself,1its children.sort_on (str | Iterable[str] | None) – Index to sort on; several sort on each in turn.
sort_order (str | None) –
ascendingordescending.metadata_fields (str | Iterable[str] | None) – Extra catalog metadata in each result (
_allfor every column).fullobjects (bool) – Return full serializations; much slower.
b_size (int | None) – Results per page (the site defaults to 25).
b_start (int | None) – Offset of the page.
indexes (Any) – Other catalog indexes, such as
UIDorSubject.
- Returns:
items,items_totalandbatching.- Return type:
- iter(path='/', *, query=None, portal_type=None, review_state=None, text=None, depth=None, sort_on=None, sort_order=None, metadata_fields=None, fullobjects=False, limit=None, b_size=100, **indexes)[source]#
Every result, fetching the pages as needed.
Takes the same arguments as
search(), plus:
- class plone_client.managers.search.QuerystringManager(client)[source]#
Bases:
BaseManagerCollection-style queries through
@querystring-search.- Parameters:
client (PloneClient)
- search(query, *, path='/', sort_on=None, sort_order=None, limit=None, b_size=None, b_start=None, metadata_fields=None, fullobjects=False)[source]#
Run a querystring query.
- Parameters:
query (Iterable[Mapping[str, Any]]) – Criteria, each with
i(index),o(operation) andv(value), as a Listing block stores them.path (str) – Context of the query, for relative path criteria.
sort_on (str | None) – Index to sort on.
sort_order (str | None) –
ascendingordescending.limit (int | None) – Maximum number of results.
b_size (int | None) – Results per page.
b_start (int | None) – Offset of the page.
metadata_fields (str | Iterable[str] | None) – Extra catalog metadata in each result.
fullobjects (bool) – Return full serializations.
- Returns:
items,items_totalandbatching.- Return type:
Workflow, versions and working copies of items.
- class plone_client.managers.workflow.WorkflowManager(client)[source]#
Bases:
BaseManagerWorkflow state and transitions (
@workflow).- Parameters:
client (PloneClient)
- transition(ref, transition, *, comment=None, effective=None, expires=None, include_children=False)[source]#
Run a workflow transition.
- Parameters:
ref (str) – Path or URL of the item.
transition (str) – Transition id, such as
publishorretract.comment (str | None) – Comment stored in the workflow history.
effective (str | None) – Publication date (ISO 8601).
expires (str | None) – Expiration date (ISO 8601).
include_children (bool) – Also run it on the items inside a folder.
- Returns:
The new history entry, with
review_state.- Raises:
PloneBadRequestError – If the transition is not available.
- Return type:
- class plone_client.managers.workflow.HistoryManager(client)[source]#
Bases:
BaseManagerVersions and workflow history of an item (
@history).- Parameters:
client (PloneClient)
- class plone_client.managers.workflow.WorkingCopyManager(client)[source]#
Bases:
BaseManagerWorking copies of published items (
@workingcopy).Needs
plone.app.iterateinstalled on the site.- Parameters:
client (PloneClient)
Files and images: upload, replace and download.
- plone_client.managers.files.TUS_CHUNK_SIZE = 4194304#
Chunk size for TUS uploads: 4 MiB.
- plone_client.managers.files.file_data(source, *, filename=None, content_type=None)[source]#
Value of a file or image field, as
plone.restapireads it.- Parameters:
- Returns:
data(base64),encoding,filenameandcontent-type.- Return type:
- class plone_client.managers.files.FilesManager(client)[source]#
Bases:
BaseManagerFiles and images stored in content items.
- Parameters:
client (PloneClient)
- upload(parent, source, *, portal_type=None, field=None, filename=None, content_type=None, **fields)[source]#
Create a
FileorImagefrom a file, in one request.The file travels base64 encoded inside the JSON body, which is simple and works on every site; for large files use
tus_upload().- Parameters:
parent (str) – Path or URL of the folder.
source (str | Path | bytes) – Path of the file, or its bytes.
portal_type (str | None) – Content type;
Imagefor images andFilefor anything else by default.field (str | None) – Field that holds the file;
imageforImageandfileotherwise by default.filename (str | None) – File name; required when
sourceis bytes.content_type (str | None) – Content type; guessed from the file name if missing.
fields (Any) – Other field values, such as
idortitle.
- Returns:
The new item.
- Return type:
- replace(ref, source, *, field='file', filename=None, content_type=None)[source]#
Replace the file stored in a field of an item.
- Parameters:
ref (str) – Path or URL of the item.
source (str | Path | bytes) – Path of the file, or its bytes.
field (str) – Field that holds the file (
imagefor images).filename (str | None) – File name; required when
sourceis bytes.content_type (str | None) – Content type; guessed from the file name if missing.
- Return type:
None
- tus_upload(parent, source, *, portal_type=None, field=None, filename=None, content_type=None, chunk_size=4194304)[source]#
Create an item from a large file, sent in chunks (
@tus-upload).- Parameters:
parent (str) – Path or URL of the folder.
source (str | Path | bytes) – Path of the file, or its bytes.
portal_type (str | None) – Content type;
Imagefor images andFilefor anything else by default.field (str | None) – Field that holds the file;
imageforImageandfileotherwise by default.filename (str | None) – File name; required when
sourceis bytes.content_type (str | None) – Content type; guessed from the file name if missing.
chunk_size (int) – Bytes sent per request.
- Returns:
URL of the new item.
- Return type:
- tus_replace(ref, source, *, field=None, filename=None, content_type=None, chunk_size=4194304)[source]#
Replace the file of an item with a large file (
@tus-replace).- Parameters:
ref (str) – Path or URL of the item.
source (str | Path | bytes) – Path of the file, or its bytes.
field (str | None) – Field that holds the file.
filename (str | None) – File name; required when
sourceis bytes.content_type (str | None) – Content type; guessed from the file name if missing.
chunk_size (int) – Bytes sent per request.
- Returns:
URL of the item.
- Return type:
Bases:
BaseManagerContextual information about an item.
- Parameters:
client (PloneClient)
Top navigation (
@navigation).
Breadcrumbs of an item (
@breadcrumbs).
Navigation portlet of an item (
@contextnavigation).
Navigation root of an item (
@navroot).On a multilingual site, this is the language root folder.
CMF actions available on an item (
@actions).
Comments, translations, aliases and relations.
- class plone_client.managers.discussion.CommentsManager(client)[source]#
Bases:
BaseManagerComments on an item (
@comments).Comments must be enabled on the site and on the content type.
- Parameters:
client (PloneClient)
- class plone_client.managers.discussion.TranslationsManager(client)[source]#
Bases:
BaseManagerTranslations of an item (
@translations).Needs
plone.app.multilingualinstalled on the site.- Parameters:
client (PloneClient)
- class plone_client.managers.discussion.AliasesManager(client)[source]#
Bases:
BaseManagerURL aliases and redirections (
@aliases).- Parameters:
client (PloneClient)
- class plone_client.managers.discussion.RelationsManager(client)[source]#
Bases:
BaseManagerRelations between items (
@relations).- Parameters:
client (PloneClient)
- list(*, source=None, target=None, relation=None, query_source=None, query_target=None, only_broken=False, limit=None)[source]#
Relations matching a filter.
- Parameters:
source (str | None) – Path or UID of the source item.
target (str | None) – Path or UID of the target item.
relation (str | None) – Relation name, such as
relatedItems.query_source (str | None) – Text the source title must match.
query_target (str | None) – Text the target title must match.
only_broken (bool) – Only relations whose target is gone.
limit (int | None) – Maximum number of relations returned.
- Returns:
relationsby name, withitemsanditems_total.- Return type:
Users, groups, roles and sharing.
- class plone_client.managers.users.UsersManager(client)[source]#
Bases:
BaseManagerSite users (
@users).- Parameters:
client (PloneClient)
- list(*, query=None, search=None, groups=None, limit=None)[source]#
Users of the site.
- Parameters:
- Returns:
The users.
- Return type:
- reset_password(user_id)[source]#
Send the user an email to reset the password.
- Parameters:
user_id (str) – Id of the user.
- Return type:
None
- update_password(user_id, new_password, *, old_password=None)[source]#
Set a new password.
Managers set any user’s password without the old one; users change their own by giving it.
- class plone_client.managers.users.GroupsManager(client)[source]#
Bases:
BaseManagerSite groups (
@groups).- Parameters:
client (PloneClient)
- delete(group_id)[source]#
Delete a group.
- Parameters:
group_id (str) – Id of the group.
- Return type:
None
- class plone_client.managers.users.SharingManager(client)[source]#
Bases:
BaseManagerLocal roles (
@sharing), principals and roles.- Parameters:
client (PloneClient)
Content types, their schemas, and vocabularies.
- plone_client.managers.types.TypeIds#
A list of type ids;
listitself is shadowed by the managers’ method.
- class plone_client.managers.types.TypesManager(client)[source]#
Bases:
BaseManagerContent types and their JSON schemas (
@types).- Parameters:
client (PloneClient)
- create_field(portal_type, data)[source]#
Add a field (or, with
fieldsetdata, a fieldset) to a type.Only for types whose schema is stored in the site, not in code.
- update(portal_type, data, *, name=None)[source]#
Change a type’s schema, or one of its fields or fieldsets.
- class plone_client.managers.types.VocabulariesManager(client)[source]#
Bases:
BaseManagerVocabularies and field sources.
- Parameters:
client (PloneClient)
- get(name, *, ref='/', title=None, token=None, sort_on=None, sort_order=None, b_size=None, b_start=None)[source]#
Terms of a vocabulary, a page at a time.
- Parameters:
name (str) – Vocabulary name, such as
plone.app.vocabularies.Keywords.ref (str) – Context of the vocabulary.
title (str | None) – Only terms whose title contains this text.
token (str | Iterable[str] | None) – Only the term with this token, or with these tokens.
sort_on (str | None) –
tokenortitle.sort_order (str | None) –
ascendingordescending.b_size (int | None) – Terms per page;
-1returns them all.b_start (int | None) – Offset of the page.
- Returns:
items(tokenandtitle) anditems_total.- Return type:
Block types: the blocks a Volto site offers, with their docs and schemas.
The list of blocks only exists in the frontend, so it comes from the
@blocks-schema service of the Volto server, not from plone.restapi.
Sites whose Volto does not have that service yet, clients that talk to the
backend directly, and anonymous clients get the documentation of Volto’s
core blocks that ships with plone-client instead, marked with
"source": "builtin" and a warning that says why.
- plone_client.managers.block_types.CORE_BLOCKS: dict[str, tuple[str, bool | str]] = {'description': ('Description', False), 'detachedSlate': ('Detached Slate', True), 'gridBlock': ('Grid', False), 'html': ('HTML', False), 'image': ('Image', False), 'listing': ('Listing', False), 'maps': ('Maps', False), 'search': ('Search', False), 'slate': ('Text', False), 'teaser': ('Teaser', False), 'title': ('Title', 'context'), 'toc': ('Table of Contents', False), 'video': ('Video', False)}#
Title and
restrictedof Volto’s core blocks, from its configuration."context"means the block chooser decides per content item.
- plone_client.managers.block_types.PLACEHOLDERS: dict[str, dict[str, str]] = {'gridBlock': {'allowedBlocks': '`image`, `listing`, `slate` and `teaser`', 'maxLength': '4'}}#
Values of the placeholders in the core docs, from Volto’s configuration.
Bases:
ExceptionThe site has no
@blocks-schemaservice that the client can use.- Parameters:
reason (str) – Why, for the
warningof the builtin answer.- Return type:
None
- plone_client.managers.block_types.core_docs(block_id)[source]#
Documentation of a core block, as shipped with plone-client.
- plone_client.managers.block_types.summary(docs)[source]#
First paragraph of a block’s documentation.
- plone_client.managers.block_types.builtin_list(reason)[source]#
The core blocks, in the shape of
GET @blocks-schema.
- plone_client.managers.block_types.builtin_block(block_id, reason)[source]#
One core block, in the shape of
GET @blocks-schema/<id>.
- plone_client.managers.block_types.builtin_markdown(data)[source]#
Markdown for a builtin answer, like the service’s
text/markdown.
- class plone_client.managers.block_types.BlockTypesManager(client)[source]#
Bases:
BaseManagerThe blocks a Volto site offers (
@blocks-schemaof the Volto server).Requests go to the client’s
frontend_urlwith a Bearer token, which the client gets from@loginwhen it uses basic authentication.- Parameters:
client (PloneClient)
- list(ref=None)[source]#
The blocks of the site, with their title and summary.
- Parameters:
ref (str | None) – A content item; only the blocks that editors can add to it are listed (their
restrictedis evaluated for it).- Returns:
items(id,title,description, mayberestricted),items_totalandsource:site, orbuiltinwith awarningwhen the site cannot tell.- Return type:
- markdown(block_id=None, ref=None)[source]#
The list of blocks, or one block, as Markdown.
Easier for a language model to read than the JSON schema.
- Parameters:
- Returns:
The Markdown.
- Raises:
PloneNotFoundError – If there is no such block.
- Return type:
Site configuration and maintenance.
- class plone_client.managers.site.RegistryManager(client)[source]#
Bases:
BaseManagerConfiguration registry (
@registry).- Parameters:
client (PloneClient)
- class plone_client.managers.site.ControlpanelsManager(client)[source]#
Bases:
BaseManagerControl panels (
@controlpanels).- Parameters:
client (PloneClient)
- update(panel, data, *, item=None)[source]#
Change settings of a control panel, or of an item inside it.
- class plone_client.managers.site.AddonsManager(client)[source]#
Bases:
BaseManagerAdd-ons (
@addons).- Parameters:
client (PloneClient)
- class plone_client.managers.site.ContentRulesManager(client)[source]#
Bases:
BaseManagerContent rules assigned to a folder (
@content-rules).- Parameters:
client (PloneClient)
- class plone_client.managers.site.SystemManager(client)[source]#
Bases:
BaseManagerInformation about the site and maintenance tasks.
- Parameters:
client (PloneClient)
- system()[source]#
Versions of Plone, Python, Zope and other components (
@system).Needs the Manage portal permission.