## Script (Python) "getStudentInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: change_bed.py 1117 2006-12-21 16:19:39Z joachim $ """ return Info about the current Student """ import logging logger = logging.getLogger('Student.Clearance.Info') request = context.REQUEST mtool = context.portal_membership wf = context.portal_workflow member = mtool.getAuthenticatedMember() member_id = str(member) path_info = request.get('PATH_INFO').split('/') if mtool.isAnonymousUser(): return None info = {} beds = context.portal_accommodation studs = context.students_catalog records = [r for r in beds() if r.student] list = [] to_modify = [] for r in records: info = context.getAccommodationInfo(r.student) if r.bed_type == info['student_status']: list.append("Student %s bed_type %s ok" % (r.student,r.bed_type)) continue list.append("Student %s bed_type %s != %s" % (r.student, r.bed_type, info['student_status'])) to_modify.append((r.bed,r.student,info['student_status'],info['acco_doc'])) for former_bed, student, status,acco_doc in to_modify: beds.modifyRecord(bed=former_bed,student='') code,bed = beds.searchAndReserveBed(student,status) if code > 0: #from Products.zdb import set_trace; set_trace() d = {} d['bed'] = bed d['student_status'] = status acco_info = context.waeup_tool.getAccommodationInfo(bed) d['acco_maint_code'] = acco_info.get('maintenance_code') d['acco_maint_fee'] = acco_info.get('maintenance_fee') acco_doc.edit(mapping=d) list.append("Student %s new bed %s assigned code = %s" % (student, bed, code)) return "\r".join(list)