Changeset 7105


Ignore:
Timestamp:
13 Nov 2011, 17:50:26 (13 years ago)
Author:
Henrik Bettermann
Message:

Undo r7102 and r7103.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
5 edited

Legend:

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

    r7103 r7105  
    146146        return name == self.chooseName()
    147147
    148     def chooseName(self, name=None, attr=None, ext=None):
     148    def chooseName(self, name=None, attr=None):
    149149        """Get a valid file id for applicant context.
    150150
  • main/waeup.sirp/trunk/src/waeup/sirp/imagestorage.py

    r7103 r7105  
    223223        return False
    224224
    225     def chooseName(self, name, attr=None, ext=None):
     225    def chooseName(self, name, attr=None):
    226226        """Choose a unique valid file id for the object.
    227227
     
    233233
    234234        For this default name chooser we return the given name if it
    235         is valid or ``unknown_file`` else. The `attr` and the `ext` params
    236         are not taken into account here.
     235        is valid or ``unknown_file`` else. The `attr` param is not
     236        taken into account here.
    237237        """
    238238        if self.checkName(name):
     
    344344        return fd
    345345
    346     def getFileByContext(self, context, attr=None, ext=None):
     346    def getFileByContext(self, context, attr=None):
    347347        """Get a file for given context.
    348348
     
    355355        id for the context and `attr` given.
    356356
    357         `context`, `attr` and `ext` are used to find (`context`)
     357        Both, `context` and `attr` are used to find (`context`)
    358358        and feed (`attr`) an appropriate file name chooser.
    359359
     
    364364                     :class:`DefaultFileStoreHandler`.
    365365        """
    366         file_id = IFileStoreNameChooser(context).chooseName(attr=attr, ext=ext)
     366        file_id = IFileStoreNameChooser(context).chooseName(attr=attr)
    367367        return self.getFile(file_id)
    368368
     
    378378        return
    379379
    380     def deleteFileByContext(self, context, attr=None, ext=None):
     380    def deleteFileByContext(self, context, attr=None):
    381381        """Remove file identified by `context` and `attr` if it exists.
    382382
     
    385385        id for the context and `attr` given.
    386386
    387         `context`, `attr` and `ext` are used to find (`context`)
     387        Both, `context` and `attr` are used to find (`context`)
    388388        and feed (`attr`) an appropriate file name chooser.
    389389
     
    395395
    396396        """
    397         file_id = IFileStoreNameChooser(context).chooseName(attr=attr, ext=ext)
     397        file_id = IFileStoreNameChooser(context).chooseName(attr=attr)
    398398        return self.deleteFile(file_id)
    399399
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r7103 r7105  
    177177        return name == self.chooseName()
    178178
    179     def chooseName(self, name=None, attr=None, ext=u''):
     179    def chooseName(self, name=None, attr=None):
    180180        """Get a valid file id for student context.
    181181
    182182        *Example:*
    183183
    184         For a student with student id ``'A123456'``,
    185         with attr ``'nice_image'`` and an uploaded file named
    186         `'anybasename.JPG'`` to be stored in
     184        For a student with student id ``'A123456'`` and
     185        with attr ``'nice_image'`` stored in
    187186        the students container this chooser would create:
    188187
     
    195194
    196195        """
    197         if name and name.count('.') == 1:
    198             basename, ext = os.path.splitext(name)
    199             ext.lower()
    200196        stud_id = self.context.student_id
    201         marked_filename = '__%s__%s/%s/%s_%s%s' % (
    202             STUDENT_FILE_STORE_NAME, stud_id[0], stud_id, attr, stud_id, ext)
     197        marked_filename = '__%s__%s/%s/%s_%s.jpg' % (
     198            STUDENT_FILE_STORE_NAME, stud_id[0], stud_id, attr, stud_id)
    203199        return marked_filename
    204200
  • main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py

    r7103 r7105  
    198198        return self.view.application_url() + rel_link
    199199
    200 def handle_file_upload(upload, context, view, max_size, attr=None):
     200def handle_img_upload(upload, context, view, max_size, attr=None):
    201201    """Handle upload of applicant image.
    202202
     
    212212    upload.seek(0) # file pointer moved when determining size
    213213    store = getUtility(IExtFileStore)
    214     file_id = IFileStoreNameChooser(
    215         context).chooseName(attr=attr, name=upload.filename)
     214    file_id = IFileStoreNameChooser(context).chooseName(attr=attr)
    216215    store.createFile(file_id, upload)
    217216    return True
     
    253252        if upload:
    254253            # We got a fresh upload
    255             file_changed = handle_file_upload(
     254            file_changed = handle_img_upload(
    256255                upload, self.context, self.view, self.mus, self.attr)
    257256            if file_changed is False:  # False is not None!
     
    288287    grok.baseclass()
    289288    attr = None
    290     ext = u'.jpg'
    291289
    292290    def render(self):
     
    294292        # for file storage.
    295293        image = getUtility(IExtFileStore).getFileByContext(
    296             self.context, attr=self.attr, ext=self.ext)
     294            self.context, attr=self.attr)
    297295        self.response.setHeader(
    298296            'Content-Type', 'image/jpeg')
     
    307305    grok.name('birth_certificate.jpg')
    308306    attr = u'birth_certificate'
    309     ext = u'.jpg'
  • main/waeup.sirp/trunk/src/waeup/sirp/tests/test_imagestorage.py

    r7103 r7105  
    158158        self.context = context
    159159
    160     def chooseName(self, name=None, attr=None, ext=None):
     160    def chooseName(self, name=None, attr=None):
    161161        # this name chooser returns different file ids depending on
    162162        # the `attr` parameter, a simple string.
Note: See TracChangeset for help on using the changeset viewer.