source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_531_resolve.py @ 5570

Last change on this file since 5570 was 3464, checked in by Henrik Bettermann, 17 years ago

this little mistake caused some trouble in the morning ...

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1## Script (Python) "ti_531_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 3464 2008-04-22 05:29:38Z 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','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 = 200
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    if count and not count % commit_after:
50        context.waeup_tool.doCommit()
51        logger.info("commiting %d transaction of %d" % (commit_after,count))
52    try:
53        getattr(student_object,manage_delObjects,'')
54    except:
55        student_object.manage_permission("Delete objects",roles=['Manager',])
56    try:
57        student_object.manage_delObjects('pume',)
58        count += 1
59        logger.info('deleted Pume object of %s %d/%d' % (student_id,count,total))
60    except:
61        student_object.manage_permission("Delete objects",roles=['Manager',])
62        not_deleted += 1
63        logger.info('could not delete Pume object of %s %d' % (student_id,not_deleted))
64logger.info('finished deleting %d not deleted %d' % (count,not_deleted))
65
66
Note: See TracBrowser for help on using the repository browser.