source: WAeUP_SRP/base/skins/waeup_student/admitStudents.py @ 2725

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

final settings before running the admit script

  • Property svn:keywords set to Id
File size: 2.0 KB
RevLine 
[2540]1## Script (Python) "admitStudents"
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: admitStudents.py 2671 2007-11-15 22:32:51Z 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
[2575]24entry_session = '07'
[2576]25pin_password = False
[2540]26
27import logging
28import DateTime
29logger = logging.getLogger('Skins.admitStudents')
30from Products.AdvancedQuery import Eq, Between, Le,In
31aq_applicants = context.applicants_catalog.evalAdvancedQuery
32request = context.REQUEST
33session = request.SESSION
34response = request.RESPONSE
35setheader = request.RESPONSE.setHeader
36def rwrite(s):
37    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
38    response.write("%s<br>\n\r" % s)
39
[2575]40brains = aq_applicants(In('status',('admitted'),))
[2540]41total = len(brains)
42logger.info("found %d students" % (total))
43count = 0
44admitted = 0
45cocount = 0
[2671]46commit_after = 20
[2540]47d = {'status': 'created'}
48reg_nos = [brain.reg_no for brain in brains]
49for reg_no in reg_nos:
50    count += 1
51    if admitted and not admitted % commit_after:
52        context.waeup_tool.doCommit()
53        logger.info("Committing %s transactions, total %s" % (commit_after,count))
[2671]54        #cocount += 1
55        #if cocount > 1:
56        #    break
[2540]57    brain = aq_applicants(Eq('reg_no',reg_no))[0]
58    #logger.info("start creating  objects of student %s" % (brain.reg_no))
[2576]59    sid = d['student_id'] = context.waeup_tool.admitOneStudent(brain,entry_session,pin_password)
[2540]60    if sid is not None:
61        d['reg_no'] = reg_no
62        context.applicants_catalog.modifyRecord(**d)
63        logger.info("created objects of student %s with id %s" % (reg_no,sid))
64        admitted += 1
65    else:
[2576]66        logger.info("could not create objects of student %s with pin " % (reg_no,brain.pin))
[2575]67
[2540]68msg = "finished admitting %d students" % (admitted)
69logger.info(msg)
[2671]70#rwrite(msg)
71return
Note: See TracBrowser for help on using the repository browser.