## 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 """ request = context.REQUEST session = request.SESSION response = request.RESPONSE 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 = [] for sb in sbrains: em = context.getFromData_entry_mode(sb.id) ec = 'x' if em in ('UME','DE'): ec = 'cup' #cat.modifyRecord(id = sb.id,entry_mode = em) lines.append('"%s","%s","","%s",""' % (ec,sb.id,sb.em)) #rwrite(ec +"--"+ sb.id +"--"+ em +"
") else: ret = context.returning_import(matric_no=sb.matric_no) moe = ret[0].Mode_of_Entry if moe in ('DE','DIRECT', 'DIRECT ENTRY',): ec = 'de' new_em = 'DE' elif moe in ('UME','U.M.E', 'UNE',): ec = 'ume' new_em ="UME" else: ec = 'unk' new_em = 'unknown' moe = 'none' #app = getattr(getattr(students,sb.id),'application',None) #if app is not None: #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 = "") lines.append('"%s","%s","%s","%s","%s"' % (ec,sb.id,sb.matric_no,moe,new_em)) #rwrite(ec +"--"+ sb.id +"--"+ em +"--"+ moe +"--"+ new_em +"
") 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)