Ignore:
Timestamp:
12 Nov 2011, 06:47:00 (13 years ago)
Author:
uli
Message:

Use path to default passport image instead of open file descriptor.
If we would use a file descriptor, we had to make sure to reset it after
each read (seek(0), which did not happen) and we could run into trouble
when multiple requests/threads access the file at the same time.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r7086 r7089  
    6868    IApplicant, IApplicantPrincipal,IApplicantEdit, IApplicantsRoot,
    6969    IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab,
    70      DEFAULT_PASSPORT_IMAGE_MALE, MAX_UPLOAD_SIZE,
     70    DEFAULT_PASSPORT_IMAGE_PATH, MAX_UPLOAD_SIZE,
    7171    )
    7272from waeup.sirp.applicants.workflow import INITIALIZED, STARTED
     
    655655        img = getUtility(IExtFileStore).getFileByContext(self.context)
    656656        if img is None:
    657             img = DEFAULT_PASSPORT_IMAGE_MALE
     657            img = open(DEFAULT_PASSPORT_IMAGE_PATH, 'rb')
    658658        doc_img = Image(img.name, width=4*cm, height=3*cm, kind='bound')
    659659        story.append(doc_img)
     
    868868        if image is None:
    869869            # show placeholder image
    870             return DEFAULT_PASSPORT_IMAGE_MALE
     870            return open(DEFAULT_PASSPORT_IMAGE_PATH, 'rb').read()
    871871        return image
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r7086 r7089  
    4848    'static'
    4949    )
    50 DEFAULT_PASSPORT_IMAGE_MALE = open(
    51     os.path.join(IMAGE_PATH, 'placeholder_m.jpg'))
     50
     51#: Filesystem path to default passport image
     52DEFAULT_PASSPORT_IMAGE_PATH = os.path.join(IMAGE_PATH, 'placeholder_m.jpg')
    5253
    5354#: Maximum upload size for applicant passport photographs (in bytes)
Note: See TracChangeset for help on using the changeset viewer.