Changeset 1882 for WAeUP_SRP/trunk/Extensions
- Timestamp:
- 12 Jun 2007, 08:18:16 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Extensions/SetupDemoDB.py
r1878 r1882 19 19 # $Id$ 20 20 """ 21 remove Data from live db to make a demodb 21 remove Data from live db to make a demodb 22 22 """ 23 23 import random 24 24 import transaction 25 25 import logging 26 logger = logging.getLogger('Extension. removeStudents')26 logger = logging.getLogger('Extension.SetupDemoDB.removeStudents') 27 27 28 28 def removeStudents(self): … … 34 34 roles = member.getRolesInContext(context) 35 35 stdir = context.portal_directories.students 36 students_catalog = context.students_catalog36 #students_catalog = context.students_catalog 37 37 students = context.portal_url.getPortalObject().campus.students 38 step = 10 39 all = students_catalog() 38 step = 5 39 #all = students_catalog() 40 all=students.objectIds() 40 41 todel = (len(all)/10) 41 42 sample = random.sample(all,todel) 42 logger.info("starting to delete %d students" % todel) 43 logger.info("starting to delete %d students" % todel) 43 44 for i in range(0,len(sample),step): 44 ids = [b .idfor b in sample[i:i + step]]45 logger.info("deleting students %s" % (ids)) 45 ids = [b for b in sample[i:i + step]] 46 logger.info("deleting students %s" % (ids)) 46 47 for sid in ids: 47 48 if hasattr(stdir, sid): … … 50 51 students.manage_delObjects(ids) 51 52 except: 52 logger.info("erro deleting %s" % (ids))53 logger.info("error deleting %s" % (ids)) 53 54 logger.info("deleted %d students %s" % (step,ids)) 54 55 transaction.commit()
Note: See TracChangeset for help on using the changeset viewer.