source: WAeUP_SRP/trunk/skins/waeup_utilities/set_current_session.py @ 1757

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

disable event_service before running

  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1## Script (Python) "set_current_session"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST
8##title=
9##
10# $Id: set_current_session.py 1757 2007-05-08 17:22:45Z joachim $
11"""
12set current_session of all students
13"""
14import logging
15logger = logging.getLogger('Skins.set_current_session')
16
17request = REQUEST
18response = request.RESPONSE
19try:
20    from Products.zdb import set_trace
21except:
22    def set_trace():
23        pass
24
25def rwrite(s):
26    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
27    #response.setHeader('Content-length','%d' % (len(s)))
28    #response.setStatus('OK')
29    response.write("%s <br/>\n\r" % s)
30    return
31
32mtool = context.portal_membership
33member = mtool.getAuthenticatedMember()
34students_catalog = context.students_catalog
35students_folder = context.portal_url.getPortalObject().campus.students
36
37#rwrite("start")
38if str(member) not in ('admin','joachim'):
39    return
40all = students_catalog()
41logger.info('%s starts to set %s ' % (member,len(all)))
42c = 0
43count = 0
44not_count = 0
45#set_trace()
46for student in all:
47    c += 1
48    if c > 1000:
49        logger.info('%s set %d not_found %d ' % (member,count,not_count))
50        c = 0
51        context.waeup_tool.doCommit()
52    if not student.session:
53        try:
54            study_course_doc = getattr(getattr(students_folder,student.id),'study_course').getContent()
55            study_course_doc.edit(mapping = {'current_session': '06'})
56            count += 1
57            data = {'session':'06'}
58            data['id'] = student.id
59            students_catalog.modifyRecord(**data)
60        except:
61            not_count += 1
62            #rwrite("%s/study_course not found" % student.id)
63
64logger.info('%s finished to set %d of %d ' % (member,count,len(all)))
65return
66
Note: See TracBrowser for help on using the repository browser.