Last change
on this file since 686 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 | """ |
---|
4 | Create an empty object in the context according to the datamodel. |
---|
5 | |
---|
6 | Datamodel may be examined to create a suitable id. |
---|
7 | """ |
---|
8 | from Products.CMFCore.utils import getToolByName |
---|
9 | |
---|
10 | prefix = datamodel.get('prefix').upper() |
---|
11 | datamodel.set('prefix',prefix) |
---|
12 | bl = context.portal_catalog({'meta_type': "ScratchCardBatch",}) |
---|
13 | b_ids = [] |
---|
14 | for b in bl: |
---|
15 | b_ids.append(b.getId) |
---|
16 | next = 1 |
---|
17 | while b_ids and "%s_%d" % (prefix,next) in b_ids: |
---|
18 | next += 1 |
---|
19 | id = "%s_%d" % (prefix,next) |
---|
20 | datamodel.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. |
---|
27 | new_id = context.invokeFactory(type_name, id, datamodel=datamodel, |
---|
28 | ) |
---|
29 | if new_id is not None: |
---|
30 | id = new_id |
---|
31 | |
---|
32 | ob = getattr(context, id) |
---|
33 | ob.getContent().edit(mapping=datamodel) |
---|
34 | |
---|
35 | #context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0 |
---|
36 | |
---|
37 | return ob |
---|
Note: See
TracBrowser for help on using the repository browser.