source: WAeUP_SRP/trunk/skins/waeup_student/scratch_card_batch_create_do.py @ 486

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

svn -R propset svn:keywords "Id" .
added layout_application_/edit/create/view
and cleaned that up.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1##parameters=type_name, datamodel
2# $Id: scratch_card_batch_create_do.py 486 2006-09-06 10:09:39Z joachim $
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('prefix').upper()
13datamodel.set('prefix',id)
14bl = context.portal_catalog({'meta_type': "ScratchCardBatch"})
15b_ids = [b.getId(), for b in bl]
16next = 1
17while "%(prefix)s_%(next)d" % vars() in b_ids:
18    next += 1
19id = "%(prefix)s_%(next)d" % vars()
20##if not id:
21##    id = 'my ' + type_name
22##id = context.computeId(compute_from=id) # XXX shouldn't use a skin
23##
24language = datamodel.get('Language')
25if not language:
26    ts = getToolByName(context, 'translation_service')
27    language = ts.getSelectedLanguage()
28
29# Datamodel is passed so that flexti can initialize the object.
30new_id = context.invokeFactory(type_name, id, datamodel=datamodel,
31                               language=language,
32                               )
33if new_id is not None:
34    id = new_id
35
36ob = getattr(context, id)
37ob.getContent().edit(mapping=datamodel)
38
39context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
40
41return ob
Note: See TracBrowser for help on using the repository browser.