[Zope-CMF] Re: Allowing content authors to only delete some content
from a folder
Heimo Laukkanen
huima at iki.fi
Sun Oct 19 12:21:57 EDT 2003
> From: Petri Savolainen <petri.savolainen at iki.fi>
> Subject: [Zope-CMF] Re: Allowing content authors to only delete some
> content from a folder
> To: zope-cmf at zope.org
> Cc: plone-users at lists.sourceforge.net
> Message-ID: <bms3jk$8ua$1 at sea.gmane.org>
> Content-Type: text/plain; charset=us-ascii; format=flowed
> What about assigning a custom condition to the "Delete" action(s)?
Mmm. But that would not limit the permissions, so person could cut an
object and paste it somewhere else etc. I decided to go with the
manage_beforeDelete.
Below is what I added to my content-type:
-----------------------------------------
from AccessControl import ClassSecurityInfo
from OFS.ObjectManager import BeforeDeleteException
security = ClassSecurityInfo()
security.declarePrivate('manage_beforeDelete')
def manage_beforeDelete(self, item, container):
membership = getToolByName( self, 'portal_membership' )
user=membership.getAuthenticatedMember()
roles = user.getRolesInContext(item)
wftool = getToolByName( self, 'portal_workflow' )
state = wftool.getInfoFor( self, 'review_state' )
if state == 'published':
raise BeforeDeleteException, 'Cant delete a
published item' + user.getUserName() + str(roles) + str(self)
BaseTemplate.manage_beforeDelete( self, item, container )
Hope this helps others.
-huima
More information about the Zope-CMF
mailing list