source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_474_resolve.py @ 16827

Last change on this file since 16827 was 3159, checked in by Henrik Bettermann, 17 years ago

tse tse tse

Wie konnte das mit den vielen set_trace() funktionieren?

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1## Script (Python) "ti_474_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_474_resolve.py 3159 2008-02-13 20:13:28Z henrik $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18
19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
21if str(member) not in ('admin','joachim'):
22    return
23
24
25import logging
26import DateTime
27logger = logging.getLogger('Skins.ti_474_resolve')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_students = context.students_catalog.evalAdvancedQuery
30aq_portal = context.portal_catalog_real.evalAdvancedQuery
31course_results = context.course_results
32aq_course_results = course_results.evalAdvancedQuery
33students_folder = context.portal_url.getPortalObject().campus.students
34
35request = context.REQUEST
36session = request.SESSION
37response = request.RESPONSE
38setheader = request.RESPONSE.setHeader
39def rwrite(s):
40    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
41    response.write("%s<br>\n\r" % s)
42course_results_to_change = []
43logger.info('start')
44#set_trace()
45for result in course_results():
46    student_id,level_id,code = result.key.split('|')
47    if result.student_id != student_id:
48        d = {}
49        d['key'] = result.key
50        d['student_id'] = student_id
51        d['level_id'] = level_id
52        course = context.courses_catalog.getRecordByKey(result.code)
53        d['credits'] = course.credits
54        d['semester'] = course.semester
55        d['session_id'] = '06'
56        course_results_to_change += d,
57logger.info('found %d correctable results' % len(course_results_to_change))
58#set_trace()
59for result in course_results_to_change:
60    try:
61        course_results.modifyRecord(**result)
62        logger.info('correcting %(key)s' % result)
63    except KeyError:
64        #set_trace()
65        logger.info('%(key)s not found there' % result)
66
67logger.info('finished')
Note: See TracBrowser for help on using the repository browser.