## Script (Python) "folder_delete" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= ## # $Id: add_course_result.py 1482 2007-02-23 16:56:46Z joachim $ """ add a course_result object. """ from urllib import urlencode request = context.REQUEST course_cat = context.courses_catalog from Products.AdvancedQuery import Eq, Between, Le,In aq_portal = context.portal_catalog.evalAdvancedQuery course_id = request.get('course_id') d = context.getCourseInfo(course_id) args = {} err = '' while True: if d['title'] == 'unknown': err = "no such course" break if context.hasObject(course_id): err = "course already exists" break if context.hasObject("%s_co" % course_id): err = "course already exists as carryover" break break if err: args['course_id'] = course_id args['error'] = err url = "%s?%s" % (context.absolute_url(),urlencode(args)) return request.RESPONSE.redirect(url) ##cert_id = context.aq_parent.getContent().study_course ##res = context.portal_catalog(portal_type="Certificate", id = cert_id) ##l = [] ##if res: ## cert = res[0] ## path = cert.getPath() ## query = Eq("path",path) &\ ## Eq('portal_type','CertificateCourse') &\ ## Eq('SearchableText', "%s" % student.level) &\ ## Eq('id',course_id) ##course = aq_portal(query)[0] cr_id = context.invokeFactory('StudentCourseResult',course_id) ##d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') ##getattr(context,cr_id).getContent().edit(mapping=d) args['course_id'] = course_id from urllib import urlencode url = "%s?%s" % (context.absolute_url(),urlencode(args)) return request.RESPONSE.redirect(url)