source: WAeUP_SRP/branches/joachim-event-branch/skins/waeup_utilities/fixEntryModeFromRegno.py @ 5529

Last change on this file since 5529 was 1475, checked in by joachim, 18 years ago

fixed application lookup

File size: 2.2 KB
Line 
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"""
12reindex students_catalog entry_mode index
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19
20request = context.REQUEST
21session = request.SESSION
22response = request.RESPONSE
23setheader = request.RESPONSE.setHeader
24students = context.portal_url.getPortalObject().campus.students
25
26def rwrite(s):
27    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
28    response.write(s)
29
30cat = context.students_catalog
31
32ems = cat.uniqueValuesFor('entry_mode')
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)))
37
38sbrains = cat()
39count = 0
40lines = []
41#set_trace()
42for sb in sbrains:
43    em = context.getFromData_entry_mode(sb.id)
44    level_cat = sb.level
45    new_em = context.getEntryMode(sb.jamb_reg_no)
46    app_found = False
47    if students.hasObject(sb.id):
48        student_obj = getattr(students,sb.id)
49        if student_obj.hasObject('application'):
50            app = getattr(student_obj,'application')
51            app.getContent().edit(mapping={'entry_mode': new_em})
52            cat.modifyRecord(id = sb.id,entry_mode = new_em)
53            app_found = True
54    if not app_found:
55        cat.modifyRecord(id = sb.id,entry_mode = "")
56    s = '"%s","%s","%s","%s","%s","%s","%s"' % (app_found,sb.id,sb.matric_no,em,
57                                                sb.jamb_reg_no,new_em,level_cat)
58    #lines.append('"%s","%s","%s","%s"' % (sb.id,sb.matric_no,moe,new_em))
59    rwrite("%s<br />" %s)
60
61#setheader('Content-type','text/semicolon-seperated-values')
62#setheader('Content-Disposition:', 'attachment; filename="fixLevelExport.csv"')
63#setheader('Expires',  'Mon, 26 Jul 1997 05:00:00GMT') # Date in the past
64#setheader('Cache-Control', 'no-store, no-cache,must-revalidate') # HTTP/1.1
65#setheader('Cache-Control', 'post-check=0,pre-check=0')
66#setheader('Pragma', 'no-cache') # HTTP/1.0
67#return '\n'.join(lines)
68
69rwrite("<br />\n Done" )
70
Note: See TracBrowser for help on using the repository browser.