source: WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py @ 405

Last change on this file since 405 was 373, checked in by joachim, 18 years ago

added verification of Courses

File size: 1.2 KB
Line 
1##parameters=type_name, datamodel
2# $Id: cpsdocument_create_do.py 34091 2006-03-06 18:37:08Z atchertchian $
3"""
4Create an empty object in the context according to the datamodel.
5
6Datamodel may be examined to create a suitable id.
7
8Returns the created object (usually a proxy).
9"""
10from Products.CMFCore.utils import getToolByName
11
12id = datamodel.get('code').upper()
13datamodel.set('code',id)
14##if not id:
15##    id = 'my ' + type_name
16##id = context.computeId(compute_from=id) # XXX shouldn't use a skin
17##
18language = datamodel.get('Language')
19if not language:
20    ts = getToolByName(context, 'translation_service')
21    language = ts.getSelectedLanguage()
22
23ttool = getToolByName(context, 'portal_types')
24ti = ttool[type_name]
25allow_discussion = ti.allowDiscussion()
26
27# Datamodel is passed so that flexti can initialize the object.
28new_id = context.invokeFactory(type_name, id, datamodel=datamodel,
29                               language=language,
30                               allow_discussion=allow_discussion)
31if new_id is not None:
32    id = new_id
33
34ob = getattr(context, id)
35ob.getContent().edit(mapping=datamodel)
36
37context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
38
39return ob
Note: See TracBrowser for help on using the repository browser.