##parameters=REQUEST,matric_no=None # $Id: set_access_data.py 1571 2007-03-17 15:25:56Z henrik $ """ process the Application Form return html renderer + psm """ import DateTime,logging current = DateTime.DateTime() pr = context.portal_registration logger = logging.getLogger('Skins.set_access_data') validate = REQUEST.has_key("cpsdocument_edit_button") if matric_no is None: logger.info('"No matric_no in request"') return REQUEST.RESPONSE.redirect("%s" % context.portal_url()) lt = context.portal_layouts #pr = context.portal_registration default = {'matric_no':matric_no} st_res = context.students_catalog(matric_no = matric_no) if st_res: sid = st_res[0].id else: logger.info('Student object with matric_no does not exist' % matric_no) res,psm,ds = lt.renderLayout(layout_id= 'student_session_results_search', schema_id= 'student_returning', context=context, mapping=validate and REQUEST, ob=default, layout_mode='edit', formaction = "set_access_data", button = "Search", matric_no = matric_no, commit = False, ) if psm == '': return context.set_access_data_form(rendered = res, psm = None, firstlayout = True, lastlayout = True, ds = ds, name = "%(name)s" % REQUEST.form ) elif psm == 'invalid': psm = "Please correct your input!" elif psm == 'valid' and not REQUEST.form.has_key('acknowledge'): psm = "You did not check the ackkowledge box!" else: password = REQUEST.get('widget__password') try: context.waeup_tool.makeStudentMember(sid,password=password) psm = '' except KeyError: #psm = "You are already registered please log in with your UserId %s" % sid psm = "" logger.info('%s repeatedly tried to set password' % sid) except: psm = "The system encountered an error. Please try again." logger.info('%s, makeStudentMember error, password = %s' % (sid,password)) if psm != '': return context.set_access_data_form(rendered = res, #psm = "%s, %s" % (psm,ds), psm = psm, firstlayout = True, lastlayout = True, ds = ds, name = "%(name)s" % REQUEST.form ) email = ds.get('email') args = {} args['__ac_name'] = sid args['__ac_password'] = password args['returning'] = '1' args['email'] = email args['phone_nr'] = ds.get('phone_nr') from urllib import urlencode url = "%s/logged_in?%s" % (context.absolute_url(),urlencode(args)) return REQUEST.RESPONSE.redirect(url)