## Script (Python) "getStudentInfo" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=student=None, with_items=None ##title= ## # $Id: getStudentInfo.py 2407 2007-10-21 06:21:25Z henrik $ """ return Info about the current Student """ request = context.REQUEST form = request.form fget = form.get wf = context.portal_workflow mtool = context.portal_membership member = mtool.getAuthenticatedMember() path_info = request.get('PATH_INFO').split('/') import logging logger = logging.getLogger('Skins.getStudentInfo') info = {} member_id = str(member) #from Products.zdb import set_trace #set_trace() student_id = None if student is None: while True: if mtool.isAnonymousUser(): return None try: requested_id = path_info[path_info.index('students')+1] except (ValueError,IndexError): student_id = member_id break if not context.isStudent() and 'students' in path_info: student_id = requested_id break if member_id != requested_id: logger.info('%s tried to access %s' % (member_id,requested_id)) student_id = member_id mtool.assertViewable(context) break student_id = member_id break else: student_id = student.getId() #roles = member.getRoles() student_path = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id) student = context.restrictedTraverse(student_path,default=None) if student is None or student.portal_type != "Student": return None info['review_state'] = context.getStudentReviewState() info['student'] = student info['id'] = student.getId() info['url'] = student.absolute_url() info['student_doc'] = student.getContent() info['app'] = student.application info['app_doc'] = student.application.getContent() course = getattr(student,'study_course',None) if course: cert_id = course.getContent().study_course res = context.portal_catalog(portal_type = "Certificate", id = cert_id) ci = {} if len(res) > 0: info['course'] = course brain = res[0] ci['study_course'] = brain.getId ci['title'] = brain.Title pl = brain.getPath().split('/') ci['faculty'] = pl[-4] ci['department'] = pl[-3] info['course_doc'] = ci else: info['course'] = None if not with_items: return info request.set('student_id',student_id) request.set('student_url',info['url']) return info