##parameters=REQUEST=None # $Id: create_studycourse.py 486 2006-09-06 10:09:39Z joachim $ """ Create a Course """ type_name = 'StudyCourse' REQUEST.set('type_name',type_name) ti = context.portal_types[type_name] pr = context.portal_registration pm = context.portal_membership validate = REQUEST.has_key("cpsdocument_create_button") lt = context.portal_layouts res,psm,ds = lt.renderLayout(layout_id= 'studycourse', schema_id = 'studycourse', context=context, mapping=validate and REQUEST, ob={}, layout_mode='create', create_action = 'create_studycourse', ) if psm == 'invalid': return context.common_edit_form(rendered = res, create = 1, type_name = type_name, psm = 'Please correct your errors', ) elif psm == '': return context.common_edit_form(rendered = res, create = 1, type_name = type_name, psm = psm, ) elif psm == 'valid': oid = "%s" % ds.get('code').replace(' ','') context.invokeFactory(type_name,oid) object = getattr(context,oid) ds.set('Title',ds.get('heading')) object.getContent().edit(mapping=ds,proxy=object) context.notifyCPSDocumentCreation(ob=object) psm = 'new %s created' % oid context_ti = context.portal_types[context.portal_type] index = context_ti.getActionById('view','university_view') return getattr(context,index)(psm=psm)