1 | ## Script (Python) "folder_delete"
|
---|
2 | ##bind container=container
|
---|
3 | ##bind context=context
|
---|
4 | ##bind namespace=
|
---|
5 | ##bind script=script
|
---|
6 | ##bind subpath=traverse_subpath
|
---|
7 | ##parameters=ids=[], REQUEST=None
|
---|
8 | ##title=
|
---|
9 | ##
|
---|
10 | # $Id: folder_delete.py 2013 2007-07-12 16:12:23Z henrik $
|
---|
11 | """
|
---|
12 | FIXME: add docstring.
|
---|
13 | """
|
---|
14 |
|
---|
15 | import logging
|
---|
16 | logger = logging.getLogger('Skins.folder_delete')
|
---|
17 | member_id = str(context.portal_membership.getAuthenticatedMember())
|
---|
18 |
|
---|
19 | from Products.CMFCore.utils import getToolByName
|
---|
20 | here = context
|
---|
21 |
|
---|
22 | ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
|
---|
23 | meth_id = ti.queryMethodID('view', 'folder_contents')
|
---|
24 | ret_url = here.absolute_url() + '/' + meth_id
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 | if ids:
|
---|
29 | for id in ids:
|
---|
30 | # XXX has to be called from here since the workflow doesn't handle the
|
---|
31 | # deletion yet
|
---|
32 | if context.portal_type == "CoursesFolder":
|
---|
33 | context.courses_catalog.deleteRecord(id)
|
---|
34 | ob = getattr(here, id)
|
---|
35 | from Products.CPSCore.EventServiceTool import getPublicEventService
|
---|
36 | evtool = getPublicEventService(here)
|
---|
37 | evtool.notifyEvent('workflow_delete', ob, {})
|
---|
38 | logger.info('%s removed object %s' % (member_id,id))
|
---|
39 | here.manage_delObjects(ids)
|
---|
40 | message = 'portal_status_message=psm_item(s)_deleted'
|
---|
41 | else:
|
---|
42 | message = 'portal_status_message=psm_select_at_least_one_document'
|
---|
43 |
|
---|
44 | if REQUEST is not None:
|
---|
45 | return REQUEST.RESPONSE.redirect(ret_url + '?' + message) |
---|