## 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 1664 2007-03-30 17:27:18Z joachim $
"""
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')
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')
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
pume_doc = pume_obj.getContent()
score = pume_doc.pume_tot_score
dict = {}
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'
dict['sex'] = 'M'
if des.sex:
dict['sex'] = 'F'
s = '%(jamb_reg_no)s with student_id %(student_id)s not in pumeresults should be recreatet
\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))
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())))