Changeset 1878
- Timestamp:
- 11 Jun 2007, 18:20:17 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Extensions/SetupDemoDB.py
r1877 r1878 22 22 """ 23 23 import random 24 import transaction 25 import logging 26 logger = logging.getLogger('Extension.removeStudents') 24 27 25 28 def removeStudents(self): … … 32 35 stdir = context.portal_directories.students 33 36 students_catalog = context.students_catalog 37 students = context.portal_url.getPortalObject().campus.students 38 step = 10 34 39 all = students_catalog() 35 sample = random.sample(all,len(all) - 1000) 36 #import pdb;pdb.set_trace() 37 for s in sample: 38 if s.matric_no: 39 context.deleteStudentByMatricNo(s.matric_no) 40 elif s.jamb_reg_no: 41 context.deleteStudentByRegNo(s.jamb_reg_no) 40 todel = (len(all)/10) 41 sample = random.sample(all,todel) 42 logger.info("starting to delete %d students" % todel) 43 for i in range(0,len(sample),step): 44 ids = [b.id for b in sample[i:i + step]] 45 logger.info("deleting students %s" % (ids)) 46 for sid in ids: 47 if hasattr(stdir, sid): 48 stdir.deleteEntry(sid) 49 try: 50 students.manage_delObjects(ids) 51 except: 52 logger.info("erro deleting %s" % (ids)) 53 logger.info("deleted %d students %s" % (step,ids)) 54 transaction.commit()
Note: See TracChangeset for help on using the changeset viewer.