## Script (Python) "ti_519_resolve" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: ti_519_resolve.py 3386 2008-03-27 16:22:52Z 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_519_resolve') from Products.AdvancedQuery import Eq, Between, Le,In aq_students = context.students_catalog.evalAdvancedQuery aq_portal = context.portal_catalog_real.evalAdvancedQuery applicants = context.applicants_catalog aq_applicants = applicants.evalAdvancedQuery pins = context.portal_pins #students_folder = context.portal_url.getPortalObject().campus.students request = context.REQUEST session = request.SESSION response = request.RESPONSE setheader = request.RESPONSE.setHeader count = 0 found = 0 commit_after = 100 logger.info('start') empty= {} for applicant in applicants(): if not (applicant.firstname or applicant.lastname or applicant.course1 or applicant.course2 ) and applicant.pin and applicant.status == "entered": d = {} key = d['key'] = getattr(applicant,applicants.key) d['pin'] = applicant.pin.replace('-','') empty[key] = d #set_trace() logger.info('found %d empty application records' % len(empty)) d = {'student':''} for applicant in empty.values(): d['pin'] = applicant['pin'] pins.modifyRecord(**d) applicants.deleteRecord(applicant['key']) logger.info("reenabled pin %(pin)s for reg_no %(key)s and deleted applicants record" % applicant) logger.info('finished')