source: WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_create_do.py @ 4831

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

Scratchcard Pin Generation
basic login in apply_admission

  • Property svn:keywords set to Id
File size: 1.0 KB
Line 
1##parameters=type_name, datamodel
2# $Id: scratch_card_batch_create_do.py 502 2006-09-11 10:39:59Z joachim $
3"""
4Create an empty object in the context according to the datamodel.
5
6Datamodel may be examined to create a suitable id.
7"""
8from Products.CMFCore.utils import getToolByName
9
10prefix = datamodel.get('prefix').upper()
11datamodel.set('prefix',prefix)
12bl = context.portal_catalog({'meta_type': "ScratchCardBatch",})
13b_ids = []
14for b in bl:
15    b_ids.append(b.getId)
16next = 1
17while b_ids and "%s_%d" % (prefix,next) in b_ids:
18    next += 1
19id = "%s_%d" % (prefix,next)
20datamodel.set('batch_no',next)
21##language = datamodel.get('Language')
22##if not language:
23##    ts = getToolByName(context, 'translation_service')
24##    language = ts.getSelectedLanguage()
25
26# Datamodel is passed so that flexti can initialize the object.
27new_id = context.invokeFactory(type_name, id, datamodel=datamodel,
28                               )
29if new_id is not None:
30    id = new_id
31
32ob = getattr(context, id)
33ob.getContent().edit(mapping=datamodel)
34
35#context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
36
37return ob
Note: See TracBrowser for help on using the repository browser.