source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_231_resolve.py @ 10955

Last change on this file since 10955 was 1833, checked in by joachim, 17 years ago

fix for #231

  • Property svn:keywords set to Id
File size: 2.3 KB
RevLine 
[1833]1## Script (Python) "ti_231_resolve"
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: ti_231_resolve.py 1833 2007-05-30 09:50:39Z joachim $
11"""
12resolve ticket #231
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19import logging
20#>>>>>>>>>>>>>>>><
21logger = logging.getLogger('Skins.ti_231_resolve')
22# logger.info('already done on  by joachim')
23# return
24#<<<<<<<<<<<<<<<<<
25from Products.AdvancedQuery import Eq, Between, Le,In
26aq_students = context.students_catalog.evalAdvancedQuery
27
28request = context.REQUEST
29session = request.SESSION
30response = request.RESPONSE
31setheader = request.RESPONSE.setHeader
32students = context.portal_url.getPortalObject().campus.students
33#from string import Template
34def rwrite(s):
35    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
36    response.write("%s<br>\n\r" % s)
37
38logger.info('ti_231 started')
39
40query = In('entry_mode',('DE','UME'))
41brains = aq_students(query)
42total = len(brains)
43logger.info('found %d students' % total)
44count = 0
45commit_after = 5
46for brain in brains:
47    try:
48        application = getattr(getattr(students,brain.id),'application')
49    except:
50        logger.info('application of %s not found' % brain.id)
51        continue
52    count += 1
53    application.getContent().edit(mapping={'entry_mode': '%s_ft' % brain.entry_mode.lower()})
54    try:
55        study_course = getattr(getattr(students,brain.id),'study_course')
56    except:
57        logger.info('study_course of %s not found' % brain.id)
58        continue
59    study_course.getContent().edit(mapping={'current_mode': '%s_ft' % brain.entry_mode.lower()})
60    logger.info('%d of %d changed  modes of %s from %s to %s_ft' % (count,
61                                                                    total,
62                                                                    brain.id,
63                                                                    brain.entry_mode,
64                                                                    brain.entry_mode.lower()
65                                                                   ))
66    if not count % commit_after:
67        context.waeup_tool.doCommit()
68        logger.info("committed %d transactions" % commit_after)
69logger.info('ti_231 finished for %d of %d' % (count,total))
Note: See TracBrowser for help on using the repository browser.