source: WAeUP_SRP/branches/joachim-azax-branch/skins/waeup_utilities/removeResults2.py @ 17937

Last change on this file since 17937 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
Line 
1## Script (Python) "removeResults2"
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"""
12remove results according to faculty-prefix
13"""
14import logging
15logger = logging.getLogger('Skins.removeResults2')
16
17request = REQUEST
18response = request.RESPONSE
19try:
20    from Products.zdb import set_trace
21except:
22    def set_trace():
23        pass
24
25def 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
31faculties_to_del = ('SCN','LSC','PSC','PHA')
32
33mtool = context.portal_membership
34member = mtool.getAuthenticatedMember()
35rcat = context.results_import
36scat = context.students_catalog
37if str(member) not in ('admin','joachim'):
38    return
39rwrite("start")
40to_del = []
41for 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 />")
45logger.info('%s starts to delete %s results' % (member,len(to_del)))
46for uid in to_del:
47    rcat.deleteRecord(uid)
48logger.info('%s finished deletion of %s results' % (member,len(to_del)))
49rwrite("Done")
50
Note: See TracBrowser for help on using the repository browser.