## Script (Python) "ti_151_resolve"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
##
# $Id: ti_165_resolve.py 1850 2007-06-03 16:54:55Z henrik $
"""
resolve ticket #151
"""
try:
from Products.zdb import set_trace
except:
def set_trace():
pass
import logging
#>>>>>>>>>>>>>>>><
logger = logging.getLogger('Skins.ti_165_resolve')
#logger.info('already done on 26.3.07 by joachim')
#return
#<<<<<<<<<<<<<<<<<
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
\n\r" % s)
def getObject(outer,object):
if outer.hasObject(object):
return getattr(outer,object)
return None
try:
from Products.AdvancedQuery import Eq, Between, Le,In
aq_students = context.students_catalog.evalAdvancedQuery
except:
evalAdvancedQuery = None
students_cat = context.students_catalog
pumeresults = context.portal_pumeresults
de_students = students_cat(entry_mode = 'de_ft')
found = 0
not_found = 0
for des in de_students:
if not des.jamb_reg_no.startswith('6'):
continue
pres = pumeresults(jamb_reg_no = des.jamb_reg_no)
if not pres:
student_obj = getObject(students,des.id)
if student_obj is None:
rwrite('%s with jamb_reg_no %s %s/%s/%s student object not found' % (des.id,
des.jamb_reg_no,
des.faculty,
des.department,
des.course,
))
continue
pume_obj = getObject(student_obj,'pume')
study_course_obj = getObject(student_obj,'study_course')
if pume_obj is None:
rwrite('%s with jamb_reg_no %s %s/%s/%s pume object not found' % (des.id,
des.jamb_reg_no,
des.faculty,
des.department,
des.course,
))
continue
dict = {}
pume_doc = pume_obj.getContent()
if study_course_obj:
study_course_doc = study_course_obj.getContent()
course_code = study_course_doc.study_course
dict['course'] = course_code
dict['course_code_org'] = course_code
score = pume_doc.pume_tot_score
dict['student_id'] = des.id
dict['jamb_reg_no'] = des.jamb_reg_no
dict['course_code'] = des.course
dict['department'] = des.department
dict['faculty'] = des.faculty
dict['name'] = des.name
dict['score'] = score
dict['result_type'] = 'de_ft'
dict['sex'] = 'M'
dict['status'] = 'Admitted'
if des.sex:
dict['sex'] = 'F'
s = '%(jamb_reg_no)s with student_id %(student_id)s not in pumeresults and is recreated
\r\n'
#s += 'Sex:%(sex)s,Name: %(name)s,Type:%(result_type)s
\n\r'
#s += 'Studycourse: %(course_code)s,Faculty: %(faculty)s,Department: %(department)s,Score: %(score)s'
rwrite(s % (dict))
pumeresults.addRecord(**dict)
not_found += 1
continue
found += 1
#rwrite('%s with jamb_reg_no %s found in pumeresults' % (des.id,des.jamb_reg_no))
rwrite('%d found in pumeresults
%d not found in pumeresults
total in portal_pumeresults %d
'
% (found,not_found,len(pumeresults())))