source: WAeUP_SRP/trunk/skins/waeup_utilities/ti_71fc_resolve_fix.py @ 5209

Last change on this file since 5209 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_71fc_resolve_fix"
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_71fc_resolve_fix.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_71fc_resolve_fix')
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)
42levels_to_look_for = ("110","210")
43course_results_to_change = []
44for result in course_results():
45    student_id,level_id,code = result.key.split('|')
46    if code != result.code:
47        d = {}
48        for field in course_results.schema():
49            d[field] = getattr(result,field)
50        d['old_key'] = d['key']
51        d['key'] = "%s|%s|%s" % (student_id,result.level_id,result.code)
52        course_results_to_change += d,
53for result in course_results_to_change:
54    try:
55        course_results.addRecord(**result)
56        logger.info('%(student_id)s adding %(key)s' % result)
57    except ValueError:
58        set_trace()
59        logger.info('%(student_id)s %(key)s already there' % result)
60    logger.info('%(student_id)s deleting %(old_key)s' % result)
61    course_results.deleteRecord(result['old_key'])
62
63logger.info('finished')
Note: See TracBrowser for help on using the repository browser.