Index: eUP_SRP/trunk/skins/waeup_epayment/purgePayments2.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/purgePayments2.py	(revision 3964)
+++ 	(revision )
@@ -1,60 +1,0 @@
-## Script (Python) "purgePayments2"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=
-##title=
-##
-# $Id: purgePayments2.py 3132 2008-02-08 21:10:38Z henrik $
-"""
-"""
-try:
-    from Products.zdb import set_trace
-except:
-    def set_trace():
-        pass
-
-mtool = context.portal_membership
-member = mtool.getAuthenticatedMember()
-if str(member) not in ('admin'):
-    return
-students_folder = context.portal_url.getPortalObject().campus.students    
-
-import logging
-import DateTime
-logger = logging.getLogger('Skins.purgePayments2')
-from Products.AdvancedQuery import Eq, Between, Le,In
-
-paid_status = ('school_fee_paid','courses_registered','courses_validated')
-students = context.students_catalog(review_state = paid_status)
-counter = 0
-counter_unpaid = 0
-commit_after = 100
-for student in students:
-    to_del = []
-    student_id = student.id
-    payments_folder = getattr(getattr(students_folder,student_id),'payments',None)       
-    payments = context.payments_catalog(student_id = student_id) 
-    for payment in payments:
-        if payment.status != 'paid':
-            counter_unpaid += 1
-        if payment.status != 'started' or payment.category != 'schoolfee':
-            continue
-        counter += 1
-        pid = 'p' + payment.order_id[6:]   
-        #logger.info('to be removed: %s, %s, %s, %s, %s' % (payment.student_id, sbrain.review_state, payment.order_id, payment.status, payment.category))
-        logger.info('object deleted: %s, %s' % (payment.student_id, pid))
-        to_del += pid,
-        if not counter % commit_after:
-            context.waeup_tool.doCommit()
-            logger.info("committing %d of total %d" % (commit_after,counter))
-        #if counter > 30:
-        #    return
-    payments_folder.manage_delObjects(to_del)
-
-logger.info("finished, %d of %d unpaid payment objects removed" % (counter, counter_unpaid))
-return 'finished!'
-
-
Index: /WAeUP_SRP/trunk/skins/waeup_epayment/purgeSFPayments.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_epayment/purgeSFPayments.py	(revision 3965)
+++ /WAeUP_SRP/trunk/skins/waeup_epayment/purgeSFPayments.py	(revision 3965)
@@ -0,0 +1,72 @@
+## Script (Python) "purgeSFPayments"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id: purgeSFPayments.py 3132 2008-02-08 21:10:38Z henrik $
+"""
+"""
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
+
+mtool = context.portal_membership
+member = mtool.getAuthenticatedMember()
+if str(member) not in ('admin'):
+    return
+students_folder = context.portal_url.getPortalObject().campus.students    
+
+import logging
+import DateTime
+logger = logging.getLogger('Skins.purgeSFPayments')
+from Products.AdvancedQuery import Eq, Between, Le,In
+
+paid_status = ('school_fee_paid','courses_registered','courses_validated')
+students = context.students_catalog(review_state = paid_status)
+counter = 0
+counter_unpaid = 0
+commit_after = 100
+records_to_del = []
+for student in students:
+    to_del = []
+    student_id = student.id
+    payments_folder = getattr(getattr(students_folder,student_id),'payments',None)       
+    payments = context.payments_catalog(student_id = student_id) 
+    for payment in payments:
+        if payment.status != 'paid':
+            counter_unpaid += 1
+        if payment.status != 'started' or payment.category != 'schoolfee':
+            continue
+        counter += 1
+        pid = 'p' + payment.order_id[6:]   
+        #logger.info('to be removed: %s, %s, %s, %s, %s' % (payment.student_id, sbrain.review_state, payment.order_id, payment.status, payment.category))
+        if getattr(payments_folder,pid,False):
+            to_del += pid,
+            logger.info('object deleted: %s, %s' % (payment.student_id, pid))
+        else:
+            logger.info('no object: %s, %s' % (payment.student_id, pid))
+            records_to_del.append(payment.order_id)
+            #context.payments_catalog.deleteRecord(payment.order_id)
+        if not counter % commit_after:
+            context.waeup_tool.doCommit()
+            logger.info("committing %d of total %d" % (commit_after,counter))
+        #if counter > 30:
+        #    return
+    payments_folder.manage_delObjects(to_del)
+context.waeup_tool.doCommit()
+logger.info("%d committed" % (counter))    
+
+for uid in records_to_del:
+    context.payments_catalog.deleteRecord(uid)        
+    logger.info("%s deleted" % (uid))    
+
+logger.info("finished, %d of %d unpaid payment objects removed" % (counter, counter_unpaid))
+return 'finished!'
+
+
