## Script (Python) "findStudentsWithCourses"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# $Id: ti_311_resolve.py 2033 2007-07-18 13:44:13Z joachim $
"""
"""
try:
    from Products.zdb import set_trace
except:
    def set_trace():
        pass
import logging
logger = logging.getLogger('Skins.ti_311_resolve')
from Products.AdvancedQuery import Eq, Between, Le,In
aq_students = context.students_catalog.evalAdvancedQuery

request = context.REQUEST
session = request.SESSION
response = request.RESPONSE
setheader = request.RESPONSE.setHeader
students = context.portal_url.getPortalObject().campus.students
#from string import Template
def rwrite(s):
    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
    response.write("%s<br>\n\r" % s)

#logger.info('')

query = Eq('review_state','courses_registered') & Eq('session','05')
brains = aq_students(query)
total = len(brains)
logger.info('found %d students with session 05 and courses_registered' % total)
count = 0
for brain in brains:
    rwrite('%s , %s ,%s, %s' % (brain.id,brain.jamb_reg_no,brain.matric_no,brain.name))
