Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

object_delete (See related posts)

// object_delete
from AccessControl import Unauthorized
from Products.CMFPlone.utils import transaction_note
from Products.CMFPlone import PloneMessageFactory as _

REQUEST = context.REQUEST
if REQUEST.get('REQUEST_METHOD', 'GET').upper() == 'GET':
    raise Unauthorized, 'This method can not be accessed using a GET request'

parent = context.aq_inner.aq_parent
parent.manage_delObjects(context.getId())

message = _(u'${title} has been deleted.',
            mapping={u'title' : context.title_or_id()})
transaction_note('Deleted %s' % context.absolute_url())

context.plone_utils.addPortalMessage(message)
return state.set(status = 'success')

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts