Deleting

Introduction

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()

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)

Table Of Contents

Previous topic

Manipulating objects

Next topic

Renaming objects (changing object ids)

This Page