source: WAeUP_SRP/base/skins/waeup_utilities/ti_531_resolve.py @ 3444

Last change on this file since 3444 was 3444, checked in by joachim, 17 years ago

remove unused pume object, fix permission on student object if necessary.

  • Property svn:keywords set to Id
File size: 1.8 KB
RevLine 
[3444]1## Script (Python) "ti_513_resolve"
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: ti_531_resolve.py 3444 2008-04-17 06:39:36Z joachim $
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','joachim'):
22    return
23
24
25import logging
26import DateTime
27logger = logging.getLogger('Skins.ti_531_resolve')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_students = context.students_catalog.evalAdvancedQuery
30aq_portal = context.portal_catalog_real.evalAdvancedQuery
31students_folder = context.portal_url.getPortalObject().campus.students
32
33request = context.REQUEST
34session = request.SESSION
35response = request.RESPONSE
36setheader = request.RESPONSE.setHeader
37count = 0
38found = 0
39not_deleted = 0
40commit_after = 100
41logger.info('start')
42students = context.students_catalog()
43pumes = aq_portal(Eq('portal_type','StudentPume'))
44total = len(pumes)
45logger.info('found %d Pume objects' % total)
46for pume in pumes:
47    student_id = pume.getPath().split('/')[-2]
48    student_object = getattr(students_folder,student_id)
49    try:
50        getattr(student_object,manage_delObjects,'')
51    except:
52        student_object.manage_permission("Delete objects",roles=['Manager',])
53    try:
54        student_object.manage_delObjects('pume',)
55        count += 1
56        logger.info('deleted Pume object of %s %d/%d' % (student_id,count,total))
57    except:
58        student_object.manage_permission("Delete objects",roles=['Manager',])
59        not_deleted += 1
60        logger.info('could not delete Pume object of %s %d' % (student_id,not_deleted))
61logger.info('finished deleting %d not deleted %d' % (count,not_deleted))
62       
63   
Note: See TracBrowser for help on using the repository browser.