source: WAeUP_SRP/branches/joachim-azax-branch/skins/waeup_accommodation/hall_delete.py @ 17952

Last change on this file since 17952 was 1566, checked in by Henrik Bettermann, 18 years ago

now logging format Part 1

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1## Script (Python) "hall_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: hall_delete.py 1566 2007-03-17 07:15:19Z henrik $
11"""
12FIXME: add docstring.
13"""
14
15import logging
16logger = logging.getLogger('Skins.hall_delete')
17member_id = str(context.portal_membership.getAuthenticatedMember())
18
19from Products.CMFCore.utils import getToolByName
20here = context
21if context.portal_type == "University":
22    here = context.academics
23
24ti = getToolByName(here, 'portal_types').getTypeInfo(here.portal_type)
25meth_id = ti.queryMethodID('view', 'folder_contents')
26ret_url = here.absolute_url() + '/' + meth_id
27pa = context.portal_accommodation
28
29if ids:
30    halls = []
31    for id in ids:
32        # XXX has to be called from here since the workflow doesn't handle the
33        # deletion yet
34        halls.append(id)
35        ob = getattr(here, id)
36        from Products.CPSCore.EventServiceTool import getPublicEventService
37        evtool = getPublicEventService(here)
38        evtool.notifyEvent('workflow_delete', ob, {})
39        beds = pa(hall=id)
40        urls = []
41        for bed in beds:
42            urls.append(bed.bed)
43        for url in urls:
44            pa.deleteRecord(url)
45    here.manage_delObjects(ids)
46    message = 'portal_status_message=hall(s) %s with %s beds deleted' % (" ".join(halls),len(urls))
47    logger.info('%s deletes hall(s) %s with %s beds' % (member_id," ".join(halls),len(urls)))
48else:
49    message = 'portal_status_message=psm_select_at_least_one_document'
50
51if REQUEST is not None:
52    return REQUEST.RESPONSE.redirect(ret_url + '?' + message)
Note: See TracBrowser for help on using the repository browser.