Last change
on this file since 16680 was
1567,
checked in by Henrik Bettermann, 18 years ago
|
new logging format Part 2
|
-
Property svn:keywords set to
Id
|
File size:
1.2 KB
|
Rev | Line | |
---|
[1567] | 1 | ## Script (Python) "removeResults2" |
---|
[1508] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=REQUEST |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: removeResults2.py 1567 2007-03-17 08:34:51Z henrik $ |
---|
| 11 | """ |
---|
| 12 | remove results according to faculty-prefix |
---|
| 13 | """ |
---|
| 14 | import logging |
---|
[1567] | 15 | logger = logging.getLogger('Skins.removeResults2') |
---|
[1508] | 16 | |
---|
| 17 | request = REQUEST |
---|
| 18 | response = request.RESPONSE |
---|
| 19 | try: |
---|
| 20 | from Products.zdb import set_trace |
---|
| 21 | except: |
---|
| 22 | def set_trace(): |
---|
| 23 | pass |
---|
| 24 | |
---|
| 25 | def rwrite(s): |
---|
| 26 | response.setHeader('Content-type','text/html; charset=ISO-8859-15') |
---|
| 27 | #response.setHeader('Content-length','%d' % (len(s))) |
---|
| 28 | #response.setStatus('OK') |
---|
| 29 | response.write(s) |
---|
| 30 | |
---|
| 31 | faculties_to_del = ('SCN','LSC','PSC','PHA') |
---|
| 32 | |
---|
| 33 | mtool = context.portal_membership |
---|
| 34 | member = mtool.getAuthenticatedMember() |
---|
| 35 | rcat = context.results_import |
---|
| 36 | scat = context.students_catalog |
---|
| 37 | if str(member) not in ('admin','joachim'): |
---|
| 38 | return |
---|
| 39 | rwrite("start") |
---|
| 40 | to_del = [] |
---|
| 41 | for r in rcat(): |
---|
| 42 | if r.matric_no[:3] in faculties_to_del: |
---|
| 43 | to_del.append(r.key) |
---|
| 44 | rwrite(r.matric_no + " " + r.Level +" " + r.CosCode + "<br />") |
---|
[1567] | 45 | logger.info('%s starts to delete %s results' % (member,len(to_del))) |
---|
[1508] | 46 | for uid in to_del: |
---|
| 47 | rcat.deleteRecord(uid) |
---|
[1567] | 48 | logger.info('%s finished deletion of %s results' % (member,len(to_del))) |
---|
[1508] | 49 | rwrite("Done") |
---|
| 50 | |
---|
Note: See
TracBrowser for help on using the repository browser.