## Script (Python) "ti_507_resolve" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: ti_507_resolve.py 3353 2008-03-19 08:35:45Z joachim $ """ """ try: from Products.zdb import set_trace except: def set_trace(): pass mtool = context.portal_membership member = mtool.getAuthenticatedMember() if str(member) not in ('admin','joachim'): return import logging import DateTime logger = logging.getLogger('Skins.ti_507_resolve') from Products.AdvancedQuery import Eq, Between, Le,In aq_students = context.students_catalog.evalAdvancedQuery aq_portal = context.portal_catalog_real.evalAdvancedQuery students_folder = context.portal_url.getPortalObject().campus.students request = context.REQUEST session = request.SESSION response = request.RESPONSE setheader = request.RESPONSE.setHeader logger.info('start') count = 0 found = 0 commit_after = 10000 certificates = context.getCertificatesDict() students = context.students_catalog() wrong = [] missing_courses = [] wrong_modes = [] for student in students: count += 1 if student.entry_mode and student.course: certificate = certificates.get(student.course,None) if certificate is None: if student.course not in missing_courses: missing_courses += student.course, logger.info('missing course %s' % student.course) continue entry_mode = student.entry_mode if entry_mode != certificate.get('study_mode','xxx'): wrong += student.id, if student.entry_mode not in wrong_modes: wrong_modes += student.entry_mode, logger.info('%s != %s' % (student.entry_mode, certificates[student.course]['study_mode'])) if wrong and not (len(wrong) % commit_after): logger.info('found %d wrong of %d' % (len(wrong),count)) logger.info('wrong modes %s' % (', '.join(wrong_modes))) logger.info('missing courses %s' % (', '.join(missing_courses))) logger.info('found %d wrong of %d' % (len(wrong),count))