RestAPI¶
- class wcs.backend.restapi.base_folder_serializer.StagingFolderSerializer(context, request)¶
Serialize a folderish object with its children.
This serializer extends the base folder serializer with two features:
- If the current object is a working copy, it extends items with children
from the baseline. This makes navigation/creating internal links much easier.
For performance reasons do not recursively include items
- class wcs.backend.restapi.base_folder_serializer.SimplelayoutStagingFolderSerializer(context, request)¶
Staging folder serializer with Simplelayout support.
Additional features beyond StagingFolderSerializer:
Expand the query by querystring parameters
Insert simplelayout blocks into result
Add layout properties to result
Sort NewsFolder by Date
Exclude Blocks from items
- wcs.backend.restapi.batching.patched_url_for_batch(self, batch)¶
Return URL that points to the given batch.
PATCH: Adding b_size by default to params.
- class wcs.backend.restapi.breadcrumbs.CustomBreadcrumbs(context, request)¶
Custom breadcrumbs implementation that extends the base Plone REST API breadcrumbs.
This class enhances the standard breadcrumbs functionality by including the portal_type for each breadcrumb item, making it easier for frontend applications to display appropriate icons or styling based on content type.
Extends plone.restapi.services.breadcrumbs.get.Breadcrumbs for IBackendLayer requests.
- class wcs.backend.restapi.easyform.EasyFormSerializeToJson(context, request)¶
EasyForm serializer with form schema and submission endpoint.
- wcs.backend.restapi.easyform.serialize_supermodel_schema(schema_class, request)¶
Convert form schema to JSON-serializable field definitions.
- Args:
schema_class: Zope schema interface to serialize request: Current HTTP request
- Returns:
list: Field definitions with name, type, title, description, required, and vocabulary items
- class wcs.backend.restapi.easyform.EasyFormSubmit¶
REST API service for EasyForm submission with CSRF protection disabled.
- reply()¶
Process the request and return a JSON serializable data structure or the no content marker if the response body should be empty.
- class wcs.backend.restapi.error.BackendErrorHandling(context, request)¶
- attempt_redirect()¶
Check if a redirect is needed, and perform it if necessary.
Returns True if a redirect has been performed, False otherwise.
This method is based on FourOhFourView.attempt_redirect() from p.a.redirector. It’s copied here because we want to answer redirects to non-GET methods with status 307, but since this method locks the response status, we wouldn’t be able to change it afterwards.
Further for 7inOne it makes sure, it does not redirect into the trash.
- class wcs.backend.restapi.expansion.BaseExpansion¶
Base class for conditional expansion logic.
Prevents unnecessary expansion of expandable elements when the current context is not the top-level URL being requested. This improves performance by only expanding elements when they’re actually needed.
- class wcs.backend.restapi.fields.CustomFileFieldSerializer(field, context, request)¶
File field serializer with enhanced download URLs.
Customizations: - Adds URL-encoded filename to download URL for better browser support - Includes cache-busting timestamp based on object modification time
- class wcs.backend.restapi.fields.CustomTextLineFieldSerializer(field, context, request)¶
TextLine field serializer with link widget support.
Automatically resolves internal links for fields that use LinkFieldWidget: - Converts resolveuid URLs to absolute URLs - Handles portal_url variable replacement - Falls back to graceful handling for broken links
- wcs.backend.restapi.fields.has_link_widget(obj, fieldname)¶
Check if a field uses the LinkFieldWidget.
- Args:
obj: Dexterity content object fieldname (str): Name of the field to check
- Returns:
bool: True if field uses LinkFieldWidget, False otherwise
- class wcs.backend.restapi.get.FileContentGet¶
Custom file GET endpoint that enables direct file downloads for anonymous users.
Customizations: - Bypasses JSON serialization for anonymous users when wcs.backend.api.directdownload is enabled - Excludes media files (audio/video) from direct download to preserve streaming behavior - Allows override via ?json=true query parameter to force JSON response
- Configuration:
Registry key: wcs.backend.api.directdownload (boolean)
- URL Examples:
GET /my-file.pdf -> direct file download (if configured) GET /my-file.pdf?json=true -> JSON metadata response
- donwload_file()¶
Trigger direct file download by delegating to @@download view.
- Returns:
Response: File download response with appropriate headers
REST service endpoint for getting navigation data.
Process the request and return a JSON serializable data structure or the no content marker if the response body should be empty.
Context navigation that only expands for top-level requests and sets default bottom level.
Enhanced recursive navigation builder with thumbnail/icon support and URL cleaning.
Customizations: - Adds thumbnail and icon support for navigation items - Prevents direct links to @@download endpoints - Converts resolveuid URLs to absolute URLs - Supports nav_title override
- Args:
children: Navigation tree children to process level (int): Current depth level in navigation tree bottomLevel (int): Maximum depth to recurse (0 = unlimited)
- Returns:
list: Processed navigation items with enhanced metadata
Process the request and return a JSON serializable data structure or the no content marker if the response body should be empty.
- class wcs.backend.restapi.principals.BackendPrincipalsGet¶
Enhanced principals search that filters AuthenticatedUsers for non-managers.
- wcs.backend.restapi.pub_start.mark_api_request_no_theme(event)¶
Disable theming for API requests and JSON Accept headers.
- Args:
event: IPubStart event containing the request
- Returns:
None: Sets X-Theme-Disabled header on matching requests
- wcs.backend.restapi.query.patched_parse_complex_query(self, idx_query)¶
Parse complex query with support for ‘not’ queries.
- Args:
idx_query (dict): Index query dictionary to parse
- Returns:
dict: Parsed query with support for both ‘query’ and ‘not’ keys
- Raises:
QueryParsingError: If both query and not keys are missing
- wcs.backend.restapi.relationfield.extended_relationvalue_converter(value)¶
Convert relation values to JSON with fullobjects support.
- Args:
value: IRelationValue to convert
- Returns:
dict|None: Full object serialization if fullobjects=1, summary otherwise, or None if no permission/object
- class wcs.backend.restapi.relationfield.RelationListFieldSerializer(field, context, request)¶
Relation list field serializer that filters out None values.
- wcs.backend.restapi.relations.patched_make_summary(obj, request)¶
Create object summary with UID always included in metadata_fields.
- Args:
obj: Object to summarize request: HTTP request containing metadata_fields and fullobjects parameters
- Returns:
dict: Object summary with UID included
- wcs.backend.restapi.relations.patched_get_relations(sources=None, targets=None, relationship=None, request=None, unrestricted=False, onlyBroken=False, max=None)¶
Get relations with trashed objects filtered out.
- Args:
sources: Source objects to find relations from targets: Target objects to find relations to relationship: Specific relationship attribute to filter by request: HTTP request object unrestricted (bool): Skip permission checks if True onlyBroken (bool): Return only broken relations if True max: Maximum number of results to return
- Returns:
dict: Relations grouped by relationship attribute, excluding trashed sources
- wcs.backend.restapi.search.patched__constrain_query_by_path(self, query)¶
If no ‘path’ query was supplied, restrict search to current context and its children by adding a path constraint.
The following cases can happen here: - No ‘path’ parameter at all - ‘path’ query dict with options, but no actual ‘query’ inside - ‘path’ supplied as a string - ‘path’ supplied as a complete query dict
- class wcs.backend.restapi.site.CustomSerializeSiteRootToJson(context, request)¶
Site root serializer that includes default page information.
- wcs.backend.restapi.utils.instert_default_page(result, context)¶
Add default page data to folder serialization result.
When a folder has a default page, this function serializes the default page and adds it to the result. Temporarily modifies REQUEST.ACTUAL_URL to ensure Simplelayout blocks attach properly to the default page.
- Args:
result (dict): Folder serialization result to modify context: Folder context object
- Returns:
None: Modifies result dict in place
- class wcs.backend.restapi.workflow.WorkflowSetState(context, request)¶
REST API service to explicitly set workflow state with security updates.
Allows direct state setting bypassing normal workflow transitions. Updates object security after state change and disables CSRF protection.
URL pattern: /@workflow-set-state/{state_id}
- reply()¶
Process the request and return a JSON serializable data structure or the no content marker if the response body should be empty.
- set_state(comment)¶
Set workflow state directly and update security.
- Args:
comment (str): Comment to record with the state change
- Raises:
ValueError: If object has no workflow or multiple workflows WorkflowException: If state_id is invalid for the workflow