## Script (Python) "folder_delete" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=ids=[], REQUEST=None ##title= ## # $Id: folder_delete.py 586 2006-09-28 22:10:21Z joachim $ """ FIXME: add docstring. """ from Products.CMFCore.utils import getToolByName here = context if context.portal_type == "University": here = context.academics ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type) meth_id = ti.queryMethodID('view', 'folder_contents') ret_url = here.absolute_url() + '/' + meth_id pa = context.portal_accommodation if ids: halls = [] for id in ids: # XXX has to be called from here since the workflow doesn't handle the # deletion yet halls.append(id) ob = getattr(here, id) from Products.CPSCore.EventServiceTool import getPublicEventService evtool = getPublicEventService(here) evtool.notifyEvent('workflow_delete', ob, {}) beds = pa(hall=id) urls = [] for bed in beds: urls.append(bed.bed) for url in urls: pa.deleteRecord(url) here.manage_delObjects(ids) message = 'portal_status_message=hall(s) %s with %s beds deleted' % (" ".join(halls),len(urls)) else: message = 'portal_status_message=psm_select_at_least_one_document' if REQUEST is not None: return REQUEST.RESPONSE.redirect(ret_url + '?' + message)