source: WAeUP_SRP/trunk/skins/waeup_utilities/setNewEntryMode.py @ 1705

Last change on this file since 1705 was 1704, checked in by joachim, 18 years ago

sets also current_mode in study_course

  • Property svn:keywords set to Id
File size: 1.4 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: setNewEntryMode.py 1704 2007-04-24 18:15:34Z 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<br />\r\n" % s)
29
30brains = context.portal_catalog(portal_type = 'Student')
31count = 0
32#set_trace()
33for brain in brains:
34    student_path = brain.getPath()
35    sub_brains = context.portal_catalog(path = student_path)
36    app_doc = None
37    sc_doc = None
38    for sb in sub_brains:
39        if sb.getId == 'application':
40            app_doc = sb.getObject().getContent()
41        elif sb.getId == 'study_course':
42            sc_doc = sb.getObject().getContent()
43    if app_doc is None:
44        continue
45    em = getattr(app_doc,'entry_mode',None)
46    new_em = "%s_ft" % em.lower()
47    app_doc.edit(mapping={'entry_mode': new_em})
48    if sc_doc:
49        sc_doc.edit(mapping={'current_mode': new_em})
50    count += 1
51    s = "%d: %s %s -> %s" % (count,brain.getPath(),em,new_em)
52    rwrite(s)
53rwrite('Done')
Note: See TracBrowser for help on using the repository browser.