source: WAeUP_SRP/trunk/skins/waeup_utilities/upgradePayments.py @ 8794

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

deactivate updatePayments

File size: 2.0 KB
Line 
1## Script (Python) "upgradePayments.py"
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: upgradePayments.py 2931 2007-12-13 06:32:18Z 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.upgradePayments')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_portal = context.portal_catalog_real.evalAdvancedQuery
30aq_student = context.students_catalog.evalAdvancedQuery
31students_folder = context.portal_url.getPortalObject().campus.students
32
33request = context.REQUEST
34session = request.SESSION
35response = request.RESPONSE
36setheader = request.RESPONSE.setHeader
37#def rwrite(s):
38#    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
39#    response.write("%s<br>\n\r" % s)
40
41count = 1
42d = {}
43l = []
44sum_total = 0.0
45log_after = 100
46logger.info("start")
47query = Eq('portal_type','Payment')
48payments = aq_portal(query,sortSpecs=('container_path',))
49total = len(payments)
50logger.info("found %d payments" % total)
51sid = "xxx"
52count = 0
53commit_after = 500
54commit_count = 0
55
56student_id = ''
57for payment_brain in payments:
58    count += 1
59    payment = payment_brain.getObject()
60    if payment_brain.getPath().split('/')[-3] != student_id:
61        student_id = payment_brain.getPath().split('/')[-3]
62        student_record = context.students_catalog.getRecordByKey(student_id)
63    payment['updatePayment'](student_record)
64    #logger.info('upgraded student %s payment %s' % (student_record.id,payment.getId()))
65    if not count % commit_after:
66        logger.info("committing %d total %d" % (commit_after,count))
67        commit_count += 1
68        context.waeup_tool.doCommit()
69        #if not commit_count % 2:
70        #    break
71logger.info("%d of %d upgraded" % (count,total))
Note: See TracBrowser for help on using the repository browser.