- Timestamp:
- 13 Nov 2011, 10:22:25 (13 years ago)
- 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
r7067 r7103 146 146 return name == self.chooseName() 147 147 148 def chooseName(self, name=None, attr=None ):148 def chooseName(self, name=None, attr=None, ext=None): 149 149 """Get a valid file id for applicant context. 150 150 -
main/waeup.sirp/trunk/src/waeup/sirp/imagestorage.py
r7093 r7103 223 223 return False 224 224 225 def chooseName(self, name, attr=None ):225 def chooseName(self, name, attr=None, ext=None): 226 226 """Choose a unique valid file id for the object. 227 227 … … 233 233 234 234 For this default name chooser we return the given name if it 235 is valid or ``unknown_file`` else. The `attr` param is not236 taken into account here.235 is valid or ``unknown_file`` else. The `attr` and the `ext` params 236 are not taken into account here. 237 237 """ 238 238 if self.checkName(name): … … 344 344 return fd 345 345 346 def getFileByContext(self, context, attr=None ):346 def getFileByContext(self, context, attr=None, ext=None): 347 347 """Get a file for given context. 348 348 … … 355 355 id for the context and `attr` given. 356 356 357 Both, `context` and `attr` are used to find (`context`)357 `context`, `attr` and `ext` are used to find (`context`) 358 358 and feed (`attr`) an appropriate file name chooser. 359 359 … … 364 364 :class:`DefaultFileStoreHandler`. 365 365 """ 366 file_id = IFileStoreNameChooser(context).chooseName(attr=attr )366 file_id = IFileStoreNameChooser(context).chooseName(attr=attr, ext=ext) 367 367 return self.getFile(file_id) 368 368 … … 378 378 return 379 379 380 def deleteFileByContext(self, context, attr=None ):380 def deleteFileByContext(self, context, attr=None, ext=None): 381 381 """Remove file identified by `context` and `attr` if it exists. 382 382 … … 385 385 id for the context and `attr` given. 386 386 387 Both, `context` and `attr` are used to find (`context`)387 `context`, `attr` and `ext` are used to find (`context`) 388 388 and feed (`attr`) an appropriate file name chooser. 389 389 … … 395 395 396 396 """ 397 file_id = IFileStoreNameChooser(context).chooseName(attr=attr )397 file_id = IFileStoreNameChooser(context).chooseName(attr=attr, ext=ext) 398 398 return self.deleteFile(file_id) 399 399 -
main/waeup.sirp/trunk/src/waeup/sirp/students/student.py
r7102 r7103 177 177 return name == self.chooseName() 178 178 179 def chooseName(self, name=None, attr=None ):179 def chooseName(self, name=None, attr=None, ext=u''): 180 180 """Get a valid file id for student context. 181 181 … … 195 195 196 196 """ 197 ext = u''198 197 if name and name.count('.') == 1: 199 198 basename, ext = os.path.splitext(name) 200 ext.lower()199 ext.lower() 201 200 stud_id = self.context.student_id 202 201 marked_filename = '__%s__%s/%s/%s_%s%s' % ( -
main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py
r7102 r7103 288 288 grok.baseclass() 289 289 attr = None 290 ext = u'.jpg' 290 291 291 292 def render(self): … … 293 294 # for file storage. 294 295 image = getUtility(IExtFileStore).getFileByContext( 295 self.context, attr=self.attr )296 self.context, attr=self.attr, ext=self.ext) 296 297 self.response.setHeader( 297 298 'Content-Type', 'image/jpeg') … … 306 307 grok.name('birth_certificate.jpg') 307 308 attr = u'birth_certificate' 309 ext = u'.jpg' -
main/waeup.sirp/trunk/src/waeup/sirp/tests/test_imagestorage.py
r7092 r7103 158 158 self.context = context 159 159 160 def chooseName(self, name=None, attr=None ):160 def chooseName(self, name=None, attr=None, ext=None): 161 161 # this name chooser returns different file ids depending on 162 162 # the `attr` parameter, a simple string.
Note: See TracChangeset for help on using the changeset viewer.