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 | """ |
---|
13 | try: |
---|
14 | from Products.zdb import set_trace |
---|
15 | except: |
---|
16 | def set_trace(): |
---|
17 | pass |
---|
18 | |
---|
19 | mtool = context.portal_membership |
---|
20 | member = mtool.getAuthenticatedMember() |
---|
21 | if str(member) not in ('admin','joachim'): |
---|
22 | return |
---|
23 | |
---|
24 | from Products.AdvancedQuery import Eq, In, MatchRegexp, Generic |
---|
25 | |
---|
26 | import logging |
---|
27 | import DateTime |
---|
28 | logger = logging.getLogger('Skins.writePassports') |
---|
29 | |
---|
30 | request = context.REQUEST |
---|
31 | session = request.SESSION |
---|
32 | response = request.RESPONSE |
---|
33 | setheader = request.RESPONSE.setHeader |
---|
34 | def 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 | |
---|
42 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
43 | query = In('mode',('ume_ft','ug_ft','de_ft','dp_ft','pg_ft')) |
---|
44 | students = aq_students(query) |
---|
45 | |
---|
46 | starttime = DateTime.DateTime() |
---|
47 | logger.info("Start writing %d Students Images" % len(students)) |
---|
48 | count = 0 |
---|
49 | chunk = 100 |
---|
50 | for student in students: |
---|
51 | count += 1 |
---|
52 | if count and not count % chunk: |
---|
53 | logger.info("written %d of %d Students Images " % (count,len(students))) |
---|
54 | context.waeup_tool.movePassportToFS(student.id) |
---|