## 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 3361 2008-03-20 09:19:20Z 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 = 100000 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 study_mode = certificate.get('study_mode','xxx') if entry_mode != study_mode: w_count = wrong_modes.get((entry_mode,study_mode),0) if w_count == 0: logger.info('%s != %s' % (student.entry_mode, study_mode)) w_count += 1 wrong_modes[(entry_mode,study_mode)] = w_count wrong += student.id, if wrong and not (len(wrong) % commit_after): logger.info('found %d wrong of %d' % (len(wrong),count)) for k,v in wrong_modes.items(): logger.info('wrong mode %s counted %d' % (k,v)) logger.info('missing courses %s' % (', '.join(missing_courses))) logger.info('found %d wrong of %d' % (len(wrong),count))