Changeset 5179 for WAeUP_SRP/trunk/skins/waeup_pins
- Timestamp:
- 30 Apr 2010, 06:39:44 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_create_do.py
r502 r5179 8 8 from Products.CMFCore.utils import getToolByName 9 9 10 #try: 11 # from Products.zdb import set_trace 12 #except: 13 # def set_trace(): 14 # pass 15 16 10 17 prefix = datamodel.get('prefix').upper() 11 18 datamodel.set('prefix',prefix) 12 19 bl = context.portal_catalog({'meta_type': "ScratchCardBatch",}) 13 20 b_ids = [] 21 14 22 for b in bl: 15 23 b_ids.append(b.getId) 16 next = 1 17 while b_ids and "%s_%d" % (prefix,next) in b_ids: 18 next += 1 24 25 p_ids = [p_id for p_id in b_ids if p_id.startswith(prefix)] 26 if p_ids: 27 max_bno = max([int(bno.split('_')[1]) for bno in p_ids]) 28 next = max_bno+1 29 else: 30 next = 1 31 32 #next = 1 33 #while b_ids and "%s_%d" % (prefix,next) in b_ids: 34 # next += 1 35 19 36 id = "%s_%d" % (prefix,next) 37 20 38 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 39 new_id = context.invokeFactory(type_name, id, datamodel=datamodel, 28 40 ) … … 33 45 ob.getContent().edit(mapping=datamodel) 34 46 35 #context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.036 37 47 return ob
Note: See TracChangeset for help on using the changeset viewer.