Ignore:
Timestamp:
4 Jan 2015, 17:19:06 (10 years ago)
Author:
Henrik Bettermann
Message:

Catch traceback when creating an application slip with a corrupted image file. This error caused a lot of trouble on KwaraPoly?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/applicant.py

    r12394 r12395  
    144144        except:
    145145            return False, 'Unknown Error'
    146         # Finally prove if the certificate still exists
     146        # Prove if the certificate still exists
    147147        try:
    148148            StudentStudyCourse().certificate = self.course_admitted
    149149        except ConstraintNotSatisfied, err:
    150150            return False, 'ConstraintNotSatisfied: %s' % self.course_admitted.code
     151        # Finally prove if an application slip can be created
     152        try:
     153            applicant_slip = getAdapter(self, IPDF, name='application_slip')(
     154                view=view)
     155        except IOError:
     156            return False, _('IOError: Application Slip could not be created.')
    151157        # Add student
    152158        site = grok.getSite()
     
    165171        notify(grok.ObjectModifiedEvent(student))
    166172        # Save application slip
    167         try:
    168             self._createApplicationPDF(student, view=view)
    169             return True, _('Student ${a} created', mapping = {'a':student.student_id})
    170         except IOError:
    171             return False, _('IOError: Application Slip could not be created.')
    172 
    173     def _createApplicationPDF(self, student, view=None):
     173        self._saveApplicationPDF(student, applicant_slip, view=view)
     174        return True, _('Student ${a} created', mapping = {'a':student.student_id})
     175
     176    def _saveApplicationPDF(self, student, applicant_slip, view=None):
    174177        """Create an application slip as PDF and store it in student folder.
    175178        """
    176179        file_store = getUtility(IExtFileStore)
    177         applicant_slip = getAdapter(self, IPDF, name='application_slip')(
    178             view=view)
    179180        file_id = IFileStoreNameChooser(student).chooseName(
    180181            attr="application_slip.pdf")
Note: See TracChangeset for help on using the changeset viewer.