source: WAeUP_SRP/trunk/skins/waeup_utilities/setEntryModeNewUME.py @ 9728

Last change on this file since 9728 was 1385, checked in by joachim, 18 years ago

set the entry_mode of level 100 student with entry_mode == "None" to UME in students_catalog and application-object

  • Property svn:keywords set to Id
File size: 1.5 KB
RevLine 
[1385]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: setEntryModeNewUME.py 1385 2007-02-01 20:43:29Z 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
31ume_100 = cat(entry_mode = 'None', level = '100')
32rwrite("entry_mode (100): %s = %d<br />\n" % ('None',len(ume_100)))
33de_100 = cat(entry_mode = 'DE', level = '100')
34rwrite("entry_mode (100): %s = %d<br />\n" % ('DE',len(de_100)))
35##from Products.zdb import set_trace;set_trace()
36count = 0
37lc = 1
38for s in ume_100:
39    student = getattr(students,s.id,None)
40    if s is None:
41        rwrite('X')
42        continue
43    cat.modifyRecord(id = s.id, entry_mode='UME')
44    ec = 'C'
45    app = getattr(student,'application',None)
46    if app is not None:
47        app.getContent().edit(mapping={'entry_mode': "UME"})
48        ec = 'A'
49    rwrite(ec)
50    count += 1
51    if count > 60:
52        lc += 1
53        rwrite("<br />\n%3d " % lc)
54        count = 0
Note: See TracBrowser for help on using the repository browser.