Ignore:
Timestamp:
13 Nov 2011, 10:22:25 (13 years ago)
Author:
Henrik Bettermann
Message:

File name choosers generally don't know the extension of the file stored. So we have to feed the chooseName method with the extension (ext) of the file stored in the file system.

This may conflict somehow with the idea behind the file name chooser. I think you (Uli) intended to use only the attr parameter to select a proper extension. In my opinion it's better to use attr and ext.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/student.py

    r7102 r7103  
    177177        return name == self.chooseName()
    178178
    179     def chooseName(self, name=None, attr=None):
     179    def chooseName(self, name=None, attr=None, ext=u''):
    180180        """Get a valid file id for student context.
    181181
     
    195195
    196196        """
    197         ext = u''
    198197        if name and name.count('.') == 1:
    199198            basename, ext = os.path.splitext(name)
    200         ext.lower()
     199            ext.lower()
    201200        stud_id = self.context.student_id
    202201        marked_filename = '__%s__%s/%s/%s_%s%s' % (
  • main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py

    r7102 r7103  
    288288    grok.baseclass()
    289289    attr = None
     290    ext = u'.jpg'
    290291
    291292    def render(self):
     
    293294        # for file storage.
    294295        image = getUtility(IExtFileStore).getFileByContext(
    295             self.context, attr=self.attr)
     296            self.context, attr=self.attr, ext=self.ext)
    296297        self.response.setHeader(
    297298            'Content-Type', 'image/jpeg')
     
    306307    grok.name('birth_certificate.jpg')
    307308    attr = u'birth_certificate'
     309    ext = u'.jpg'
Note: See TracChangeset for help on using the changeset viewer.