source: WAeUP_SRP/trunk/skins/waeup_utilities/reindex_entry_mode.py @ 1388

Last change on this file since 1388 was 1380, checked in by joachim, 18 years ago

course registration

M waeup_student/student_index.py
M waeup_student/study_level_view.pt
M waeup_student/getStudyLevelInfo.py
M waeup_student/study_course_view.pt
M waeup_student/getStudyCourseInfo.py
AM waeup_academics/getCourseInfo.py

reindex entry_mode

M waeup_utilities/getFromData_entry_mode.py
M waeup_utilities/reindex_entry_mode.py

File size: 2.0 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"""
14request = context.REQUEST
15session = request.SESSION
16response = request.RESPONSE
17students = context.portal_url.getPortalObject().campus.students
18def rwrite(s):
19    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
20    #response.setHeader('Content-length','%d' % (len(s)))
21    #response.setStatus('OK')
22    response.write(s)
23   
24cat = context.students_catalog
25ems = cat.uniqueValuesFor('entry_mode')
26rwrite("entry_mode values: %s<br />\n" % (str(ems)))
27for em in ems:
28    res = cat(entry_mode = em)
29    rwrite("entry_mode: %s = %d<br />\n" % (em,len(res)))
30#from Products.zdb import set_trace;set_trace()
31sbrains = cat()
32count = 0
33lc = 1
34rwrite("%3d " % lc)
35for sb in sbrains:
36    normalized = False
37    em = context.getFromData_entry_mode(sb.id)
38    ec = 'x'
39    if em is None:
40        ec = 'n'
41        em = 'None'
42    if em in ('UME','DE'):
43        ec = 'C'
44        normalized = True
45    elif sb.entry_mode in ('DIRECT', 'DIRECT ENTRY',):
46        ec = 'D'
47        em = 'DE'
48        normalized = True
49    elif sb.entry_mode in ('U.M.E', 'UNE',):
50        ec = 'U'
51        em ="UME"
52        normalized = True
53    elif not sb.entry_mode:
54        ec = 'u'
55        em ="UME"
56        normalized = True
57    if ec != "C" and em != sb.entry_mode:
58        #from Products.zdb import set_trace;set_trace()
59        app = getattr(getattr(students,sb.id),'application',None)
60        ec = 'a'
61        if app is not None:
62            ec = 'A'
63            app.getContent().edit(mapping={'entry_mode': sb.entry_mode})
64    if normalized:
65        cat.modifyRecord(id = sb.id,
66                         entry_mode = em)
67    rwrite(ec)
68    count += 1
69    if count > 60:
70        lc += 1
71        rwrite("<br />\n%3d " % lc)
72        count = 0
73
Note: See TracBrowser for help on using the repository browser.