## Script (Python) "reindex_entry_mode" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: reindex_entry_mode.py 1328 2007-01-19 18:16:32Z joachim $ """ reindex students_catalog entry_mode index """ try: from Products.zdb import set_trace except: def set_trace(): pass request = context.REQUEST session = request.SESSION response = request.RESPONSE setheader = request.RESPONSE.setHeader students = context.portal_url.getPortalObject().campus.students def rwrite(s): response.setHeader('Content-type','text/html; charset=ISO-8859-15') response.write(s) cat = context.students_catalog ems = cat.uniqueValuesFor('entry_mode') ##rwrite("entry_mode values: %s
\n" % (str(ems))) ##for em in ems: ## res = cat(entry_mode = em) ## rwrite("entry_mode: %s = %d
\n" % (em,len(res))) sbrains = cat() count = 0 lines = [] #set_trace() for sb in sbrains: em = context.getFromData_entry_mode(sb.id) level_cat = sb.level new_em = context.getEntryMode(sb.jamb_reg_no) if students.hasObject('application'): app = getattr(getattr(students,sb.id),'application') app.getContent().edit(mapping={'entry_mode': new_em}) cat.modifyRecord(id = sb.id,entry_mode = new_em) else: cat.modifyRecord(id = sb.id,entry_mode = "") s = '"%s","%s","%s","%s","%s","%s"' % (sb.id,sb.matric_no,em, sb.jamb_reg_no,new_em,level_cat) #lines.append('"%s","%s","%s","%s"' % (sb.id,sb.matric_no,moe,new_em)) rwrite("%s
" %s) #setheader('Content-type','text/semicolon-seperated-values') #setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"') #setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past #setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 #setheader('Cache-Control', 'post-check=0,pre-check=0') #setheader('Pragma', 'no-cache') # HTTP/1.0 #return '\n'.join(lines) rwrite("
\n Done" )