Ignore:
Timestamp:
9 Nov 2007, 15:38:22 (17 years ago)
Author:
joachim
Message:

ti_391 now uses students_catalog, use levels vocabulary for study-level in academics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_utilities/ti_391_resolve.py

    r2605 r2609  
    2828from Products.AdvancedQuery import Eq, Between, Le,In
    2929aq_portal = context.portal_catalog_real.evalAdvancedQuery
     30students_folder = context.portal_url.getPortalObject().campus.students
    3031
    3132request = context.REQUEST
     
    3940#logger.info('')
    4041
    41 query = Eq('portal_type','StudentPersonal')
    42 #brains = context.students_catalog()
    43 brains = aq_portal(query)
     42#query = Eq('portal_type','StudentPersonal')
     43#brains = aq_portal(query)
     44brains = context.students_catalog()
    4445total = len(brains)
    4546#rwrite("found %d " % total)
     
    4748edited = 0
    4849count = 0
     50commit_after = 50
    4951logger.info('started for %d' % total)
    5052for brain in brains:
    5153    count += 1
    52     doc = brain.getObject().getContent()
    53     if doc.email and doc.email.find('@') < 0:
     54    if no_email and not no_email % commit_after:
     55        context.waeup_tool.doCommit()
     56        logger.info("Committing %s transactions, total %s" % (commit_after,count))
     57    if not brain.email or brain.email.find('@') < 0:
    5458        no_email += 1
    55         #rwrite ("%s email = %s" % (brain.getId,doc.email))
    5659        try:
    57             app_doc = getattr(brain.getObject().aq_parent,'application').getContent()
    58             logger.info("setting email of %s from %s to %s" % (brain.getPath().split('/')[-2],
    59                                                                doc.email,
    60                                                                app_doc.app_email))
    61             doc.edit(mapping={'email': app_doc.app_email})
    62             edited += 1
     60            app_doc = getattr(getattr(students_folder,brain.id),'application').getContent()
     61            #rwrite ("%s email = %s" % (brain.getId,doc.email))
    6362        except:
    64             logger.info("failed to set email of %s from %s" % (brain.getPath().split('/')[-2],
    65                                                                doc.email,
    66                                                                ))
    67             pass
     63            logger.info("failed to get application object of %s" % (brain.id,))
     64            continue
     65        if not app_doc.app_email or app_doc.app_email.find('@') < 0:
     66            logger.info("%s both emails %s/%s are invalid" % (brain.id,
     67                                                              app_doc.app_email,
     68                                                              brain.email))
     69            continue
     70        try:
     71            per_doc = getattr(getattr(students_folder,brain.id),'personal').getContent()
     72            #rwrite ("%s email = %s" % (brain.getId,doc.email))
     73        except:
     74            logger.info("failed to get personal object of %s" % (brain.id,))
     75            continue
     76        logger.info("setting email of %s from %s to %s" % (brain.id,
     77                                                            per_doc.email,
     78                                                            app_doc.app_email))
     79        per_doc.edit(mapping={'email': app_doc.app_email})
     80        edited += 1
    6881    else:
    6982        #rwrite ("%s email = %s" % (brain.getPath(),doc.email))
Note: See TracChangeset for help on using the changeset viewer.