source: WAeUP_SRP/trunk/skins/waeup_utilities/remove_all_accommodation_objects.py @ 15394

Last change on this file since 15394 was 5787, checked in by Henrik Bettermann, 14 years ago

Remove all accommodation objects.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1## Script (Python) "remove_all_accommodation_objects"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: remove_all_accommodation_objects.py 5787 2011-03-02 11:30:23Z henrik $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18
19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
21if str(member) not in ('admin'):
22    return
23
24import logging
25import DateTime
26logger = logging.getLogger('Skins.remove_all_accommodation_objects')
27from Products.AdvancedQuery import Eq, Between, Le,In
28aq_portal = context.portal_catalog_real.evalAdvancedQuery
29wf = context.portal_workflow
30
31logger.info('start')
32accommodation_brains = context.portal_catalog.search({'meta_type': "StudentAccommodation"})
33num_objects = len(accommodation_brains)
34logger.info("found %d StudentAccommodation objects" % num_objects)
35students_folder = context.portal_url.getPortalObject().campus.students
36
37for i in xrange(num_objects):
38    #set_trace()
39    data = {}
40    a_brain = accommodation_brains[i]
41    pl = a_brain.getPath().split('/')
42    student_id = pl[-2]   
43    student_folder = getattr(students_folder,student_id)
44    student_folder.manage_delObjects(a_brain.id)
45    logger.info("%s/%s removed" % (pl[-2],pl[-1]))
46
47logger.info("finished")
Note: See TracBrowser for help on using the repository browser.