[1334] | 1 | ## Script (Python) "reindex_entry_mode" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters= |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: reindex_entry_mode.py 1328 2007-01-19 18:16:32Z joachim $ |
---|
| 11 | """ |
---|
| 12 | reindex students_catalog entry_mode index |
---|
| 13 | """ |
---|
[1458] | 14 | try: |
---|
| 15 | from Products.zdb import set_trace |
---|
| 16 | except: |
---|
| 17 | def set_trace(): |
---|
| 18 | pass |
---|
| 19 | |
---|
[1380] | 20 | request = context.REQUEST |
---|
| 21 | session = request.SESSION |
---|
| 22 | response = request.RESPONSE |
---|
[1408] | 23 | setheader = request.RESPONSE.setHeader |
---|
[1380] | 24 | students = context.portal_url.getPortalObject().campus.students |
---|
[1392] | 25 | |
---|
[1408] | 26 | def rwrite(s): |
---|
| 27 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
| 28 | response.write(s) |
---|
[1392] | 29 | |
---|
[1334] | 30 | cat = context.students_catalog |
---|
[1392] | 31 | |
---|
[1408] | 32 | ems = cat.uniqueValuesFor('entry_mode') |
---|
[1458] | 33 | ##rwrite("entry_mode values: %s<br />\n" % (str(ems))) |
---|
| 34 | ##for em in ems: |
---|
| 35 | ## res = cat(entry_mode = em) |
---|
| 36 | ## rwrite("entry_mode: %s = %d<br />\n" % (em,len(res))) |
---|
[1392] | 37 | |
---|
[1334] | 38 | sbrains = cat() |
---|
[1380] | 39 | count = 0 |
---|
[1392] | 40 | lines = [] |
---|
[1458] | 41 | #set_trace() |
---|
[1334] | 42 | for sb in sbrains: |
---|
[1380] | 43 | em = context.getFromData_entry_mode(sb.id) |
---|
| 44 | ec = 'x' |
---|
[1408] | 45 | level_cat = sb.level |
---|
[1458] | 46 | new_em = context.getEntryMode(sb.jamb_reg_no) |
---|
| 47 | if students.hasObject('application'): |
---|
| 48 | app = getattr(getattr(students,sb.id),'application') |
---|
| 49 | app.getContent().edit(mapping={'entry_mode': new_em}) |
---|
| 50 | cat.modifyRecord(id = sb.id,entry_mode = new_em) |
---|
[1389] | 51 | else: |
---|
[1458] | 52 | cat.modifyRecord(id = sb.id,entry_mode = "") |
---|
| 53 | s = '"%s","%s","%s","%s","%s","%s","%s"' % (ec,sb.id,sb.matric_no,em, |
---|
| 54 | sb.jamb_reg_no,new_em,level_cat) |
---|
| 55 | #lines.append('"%s","%s","%s","%s","%s"' % (ec,sb.id,sb.matric_no,moe,new_em)) |
---|
| 56 | rwrite("%s<br />" %s) |
---|
[1334] | 57 | |
---|
[1408] | 58 | #setheader('Content-type','text/semicolon-seperated-values') |
---|
| 59 | #setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"') |
---|
| 60 | #setheader('Expires', 'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past |
---|
| 61 | #setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1 |
---|
| 62 | #setheader('Cache-Control', 'post-check=0,pre-check=0') |
---|
| 63 | #setheader('Pragma', 'no-cache') # HTTP/1.0 |
---|
| 64 | #return '\n'.join(lines) |
---|
| 65 | |
---|
| 66 | rwrite("<br />\n Done" ) |
---|
| 67 | |
---|