#-*- mode: python; mode: fold -*- # (C) Copyright 2005 The WAeUP group # Author: Joachim Schmitz (js@aixtraware.de) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # # $Id: SetupDemoDB.py 1877 2007-06-11 12:36:10Z joachim $ """ remove Data from live db to make a demodb """ import random def removeStudents(self): "remove nearly all students to form a lightweight demodb" context = self.uniben wftool = context.portal_workflow mtool = context.portal_membership member = mtool.getAuthenticatedMember() roles = member.getRolesInContext(context) stdir = context.portal_directories.students students_catalog = context.students_catalog all = students_catalog() sample = random.sample(all,len(all) - 1000) #import pdb;pdb.set_trace() for s in sample: if s.matric_no: context.deleteStudentByMatricNo(s.matric_no) elif s.jamb_reg_no: context.deleteStudentByRegNo(s.jamb_reg_no)