Changeset 3362 for WAeUP_SRP/base


Ignore:
Timestamp:
20 Mar 2008, 16:20:15 (17 years ago)
Author:
joachim
Message:

fix for #112 okene, make create level more errortolerant

Location:
WAeUP_SRP/base
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTables.py

    r3354 r3362  
    14811481    def addMultipleRecords(self, records): ###(
    14821482        """add many records"""
    1483         added_keys = []
     1483        existing_uids = []
    14841484        for data in records:
    1485             uid = key = "%(student_id)s|%(level_id)s|%(course_id)s" % data
     1485            uid = "%(student_id)s|%(level_id)s|%(course_id)s" % data
    14861486            data['%s' % self.key] = uid
    1487             res = self.searchResults({"%s" % self.key : uid})
     1487            query = Eq(self.key, uid)
     1488            res = self.course_results.evalAdvancedQuery(query)
    14881489            if len(res) > 0:
    1489                 raise ValueError("More than one record with uid %s" % uid)
     1490                rec = res[0]
     1491                equal = True
     1492                for attr in ('student_id','level_id','course_id'):
     1493                    if getattr(rec,attr,'') != data[attr]:
     1494                        equal = False
     1495                        break
     1496                if equal:
     1497                    existing_uids += uid,
     1498                    continue
    14901499            self.catalog_object(dict2ob(data), uid=uid)
    1491         return uid
     1500        return existing_uids
    14921501    ###)
    14931502
    14941503    def deleteResultsHere(self,level_id,student_id): ###(
    1495         #import pdb;pdb.set_trace()
    14961504        query = Eq('student_id',student_id) & Eq('level_id', level_id)
    14971505        course_results = self.course_results.evalAdvancedQuery(query)
     1506        #import pdb;pdb.set_trace()
    14981507        for result in course_results:
    14991508            self.deleteRecord(result.key)
  • WAeUP_SRP/base/skins/waeup_student/create_level.py

    r3074 r3362  
    176176
    177177if records:
    178     context.course_results.addMultipleRecords(records)
     178    existing_uids = context.course_results.addMultipleRecords(records)
     179    if existing_uids:
     180        logger.info('%s level %s %s existing keys' % (student.id,
     181                                                      current_level,
     182                                                     ",".join(existing_uids)))
     183       
    179184logger.info('%s finished to create level %s' % (student.id,current_level))
    180185
  • WAeUP_SRP/base/skins/waeup_student/level_delete.py

    r2817 r3362  
    1212delete a level, fix students review if necessary
    1313"""
     14try:
     15    from Products.zdb import set_trace
     16except:
     17    def set_trace():
     18        pass
    1419
    1520import logging
    16 logger = logging.getLogger('Skins.folder_delete')
     21logger = logging.getLogger('Skins.level_delete')
    1722member_id = str(context.portal_membership.getAuthenticatedMember())
    1823
     
    5055    for level_id in ids:
    5156        context.course_results.deleteResultsHere(level_id,student_id)
     57    logger.info("%s deleted level(s) %s of %s" % (member_id,','.join(ids),student_id))
    5258    here.manage_delObjects(ids)
    53 
    5459    message = 'portal_status_message=psm_item(s)_deleted'
    5560else:
Note: See TracChangeset for help on using the changeset viewer.