source: WAeUP_SRP/base/skins/waeup_utilities/writePassports.py @ 2690

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

commit after 100 students

File size: 1.4 KB
RevLine 
[2300]1## Script (Python) "writePassports"
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: writeStudentImages.py 2292 2007-09-28 14:47:14Z joachim $
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
24from Products.AdvancedQuery import Eq, In, MatchRegexp, Generic
25
26import logging
27import DateTime
28logger = logging.getLogger('Skins.writePassports')
29
30request = context.REQUEST
31session = request.SESSION
32response = request.RESPONSE
33setheader = request.RESPONSE.setHeader
34def rwrite(s):
35    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
36    response.write("%s<br>\n\r" % s)
37
38#logger.info('')
39
40#students = context.students_catalog()
41
42aq_students = context.students_catalog.evalAdvancedQuery
43query = In('mode',('ume_ft','ug_ft','de_ft','dp_ft','pg_ft'))
44students = aq_students(query)
45
46starttime = DateTime.DateTime()
[2303]47logger.info("Start writing %d student passports" % len(students))
[2300]48count = 0
49chunk = 100
50for student in students:
51    count += 1
52    if count and not count % chunk:
[2303]53        logger.info("written %d of %d student passports " % (count,len(students)))
54        context.waeup_tool.doCommit()
[2300]55    context.waeup_tool.movePassportToFS(student.id)
Note: See TracBrowser for help on using the repository browser.