Ignore:
Timestamp:
12 Jun 2007, 08:18:16 (18 years ago)
Author:
Henrik Bettermann
Message:

that works (slowly but steadily)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Extensions/SetupDemoDB.py

    r1878 r1882  
    1919# $Id$
    2020"""
    21 remove Data from live db to make a demodb 
     21remove Data from live db to make a demodb
    2222"""
    2323import random
    2424import transaction
    2525import logging
    26 logger = logging.getLogger('Extension.removeStudents')
     26logger = logging.getLogger('Extension.SetupDemoDB.removeStudents')
    2727
    2828def removeStudents(self):
     
    3434    roles = member.getRolesInContext(context)
    3535    stdir = context.portal_directories.students
    36     students_catalog = context.students_catalog
     36    #students_catalog = context.students_catalog
    3737    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()
    4041    todel = (len(all)/10)
    4142    sample = random.sample(all,todel)
    42     logger.info("starting to delete %d students" % todel) 
     43    logger.info("starting to delete %d students" % todel)
    4344    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)) 
     45        ids = [b  for b in sample[i:i + step]]
     46        logger.info("deleting students %s" % (ids))
    4647        for sid in ids:
    4748            if hasattr(stdir, sid):
     
    5051            students.manage_delObjects(ids)
    5152        except:
    52             logger.info("erro deleting %s" % (ids))
     53            logger.info("error deleting %s" % (ids))
    5354        logger.info("deleted %d students %s" % (step,ids))
    5455        transaction.commit()
Note: See TracChangeset for help on using the changeset viewer.