[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 | """ |
---|
| 13 | try: |
---|
| 14 | from Products.zdb import set_trace |
---|
| 15 | except: |
---|
| 16 | def set_trace(): |
---|
| 17 | pass |
---|
| 18 | |
---|
| 19 | mtool = context.portal_membership |
---|
| 20 | member = mtool.getAuthenticatedMember() |
---|
| 21 | if str(member) not in ('admin','joachim'): |
---|
| 22 | return |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | import logging |
---|
| 26 | import DateTime |
---|
| 27 | logger = logging.getLogger('Skins.ti_531_resolve') |
---|
| 28 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
| 29 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
| 30 | aq_portal = context.portal_catalog_real.evalAdvancedQuery |
---|
| 31 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
| 32 | |
---|
| 33 | request = context.REQUEST |
---|
| 34 | session = request.SESSION |
---|
| 35 | response = request.RESPONSE |
---|
| 36 | setheader = request.RESPONSE.setHeader |
---|
| 37 | count = 0 |
---|
| 38 | found = 0 |
---|
| 39 | not_deleted = 0 |
---|
| 40 | commit_after = 100 |
---|
| 41 | logger.info('start') |
---|
| 42 | students = context.students_catalog() |
---|
| 43 | pumes = aq_portal(Eq('portal_type','StudentPume')) |
---|
| 44 | total = len(pumes) |
---|
| 45 | logger.info('found %d Pume objects' % total) |
---|
| 46 | for 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)) |
---|
| 61 | logger.info('finished deleting %d not deleted %d' % (count,not_deleted)) |
---|
| 62 | |
---|
| 63 | |
---|