(削除)

はじめに

This document tells how to programmatically delete objects in Plone.

Deleting content by id

Deleting content objects is done by IObjectManager.

IObjectManager definition.

Example:

# manage_delObjects takes list of ids as an argument
folder.manage_delObjects(["list", "of", "ids", "to", "delete"])

Or:

parent = context.aq_parent
parent.manage_delObjects([context.getId()])

Deleting all content in a folder

Little tricky. An example:

    ids = folder.objectIds() # Plone 3 or older
    ids = folder.keys()      # Plone 4 or newer

if len(ids) > 0:
    # manage_delObject will mutate the list
    # so we cannot give it tuple returned by objectIds()
    ids = list(ids)
    folder.manage_delObjects(ids)

目次

前のトピックへ

(オブジェクトの操作)

次のトピックへ

(オブジェクトの名前を変更 (オブジェクト id の変更))

このページ