GitHub-only
WARNING: If you are reading this on GitHub, DON'T! Read the documentation at api.plone.org so you have working references and proper formatting.
plone.api.content¶
Module that provides functionality for content manipulation.
- plone.api.content.copy(source=None, target=None, id=None, safe_id=False)¶
Copy the object to the target container.
Parameters: - source (Content object) -- [required] Object that we want to copy.
- target (Folderish content object) -- Target container to which the source object will be moved. If no target is specified, the source object's container will be used as a target.
- id (string) -- Id of the copied object on the target location. If no id is provided, the copied object will have the same id as the source object - however, if the new object's id conflicts with another object in the target container, a suffix will be added to the new object's id.
- safe_id (boolean) -- When True, the given id will be enforced. If the id is conflicting with another object in the target container, raise a InvalidParameterError. When True, choose a new, non-conflicting id.
Returns: Content object that was created in the target location
Raises: KeyError, ValueError
Example:
- plone.api.content.create(container=None, type=None, id=None, title=None, safe_id=False, **kwargs)¶
Create a new content item.
Parameters: - container (Folderish content object) -- [required] Container object in which to create the new object.
- type (string) -- [required] Type of the object.
- id (string) -- Id of the object. If the id conflicts with another object in the container, a suffix will be added to the new object's id. If no id is provided, automatically generate one from the title. If there is no id or title provided, raise a ValueError.
- title (string) -- Title of the object. If no title is provided, use id as the title.
- safe_id (boolean) -- When False, the given id will be enforced. If the id is conflicting with another object in the target container, raise an InvalidParameterError. When True, choose a new, non-conflicting id.
Returns: Content object
Raises: KeyError, MissingParameterError, InvalidParameterError
Example:
- plone.api.content.delete(obj=None)¶
Delete the object.
Parameters: obj (Content object) -- [required] Object that we want to delete. Raises: ValueError Example: Delete content
- plone.api.content.get(path=None, UID=None)¶
Get an object.
Parameters: - path (string) -- Path to the object we want to get, relative to the portal root.
- UID (string) -- UID of the object we want to get.
Returns: Content object
Raises: ValueError,
Example:
- plone.api.content.get_state(obj=None)¶
Get the current workflow state of the object.
Parameters: obj (Content object) -- [required] Object that we want to get the state for. Returns: Object's current workflow state Return type: string Raises: ValueError Example: Get workflow state
- plone.api.content.get_uuid(obj=None)¶
Get the object's Universally Unique IDentifier (UUID).
Parameters: obj (Content object) -- [required] Object we want its UUID. Returns: Object's UUID Return type: string Raises: ValueError Example: Get content object UUID
- plone.api.content.get_view(name=None, context=None, request=None)¶
Get a BrowserView object.
Parameters: - name (string) -- [required] Name of the view.
- context (context object) -- [required] Context on which to get view.
- request (request object) -- [required] Request on which to get view.
Raises: Example:
- plone.api.content.move(source=None, target=None, id=None, safe_id=False)¶
Move the object to the target container.
Parameters: - source (Content object) -- [required] Object that we want to move.
- target (Folderish content object) -- Target container to which the source object will be moved. If no target is specified, the source object's container will be used as a target, effectively making this operation a rename (Rename content).
- id (string) -- Pass this parameter if you want to change the id of the moved object on the target location. If the new id conflicts with another object in the target container, a suffix will be added to the moved object's id.
- safe_id (boolean) -- When False, the given id will be enforced. If the id is conflicting with another object in the target container, raise a InvalidParameterError. When True, choose a new, non-conflicting id.
Returns: Content object that was moved to the target location
Raises: KeyError ValueError
Example:
- plone.api.content.rename(obj=None, new_id=None, safe_id=False)¶
Rename the object.
Parameters: - obj (Content object) -- [required] Object that we want to rename.
- new_id (string) -- New id of the object.
- safe_id (boolean) -- When False, the given id will be enforced. If the id is conflicting with another object in the container, raise a InvalidParameterError. When True, choose a new, non-conflicting id.
Returns: Content object that was renamed
Example:
- plone.api.content.transition(obj=None, transition=None, to_state=None)¶
Perform a workflow transition for the object or attempt to perform workflow transitions on the object to reach the given state. The later will not guarantee that transition guards conditions can be met.
Parameters: - obj (Content object) -- [required] Object for which we want to perform the workflow transition.
- transition (string) -- Name of the workflow transition.
- to_state (string) -- Name of the workflow state.
Raises: Example: