Changeset 7321 for main/waeup.sirp/trunk/src/waeup/sirp/image/browser
- Timestamp:
- 10 Dec 2011, 06:15:17 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/image/browser
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/image/browser/tests/image.txt
r6537 r7321 12 12 13 13 >>> import os 14 >>> from waeup.sirp.image import WAeUPImageFile14 >>> from waeup.sirp.image import SIRPImageFile 15 15 >>> testimage = os.path.join(os.path.dirname(__file__), 'sample.jpg') 16 16 >>> testimage2 = os.path.join(os.path.dirname(__file__), 'sample2.jpg') 17 >>> some_file = WAeUPImageFile('foo.jpg', open(testimage, 'rb').read())17 >>> some_file = SIRPImageFile('foo.jpg', open(testimage, 'rb').read()) 18 18 >>> some_file.filename 19 19 'foo.jpg' … … 166 166 prepare some new file: 167 167 168 >>> another_file = WAeUPImageFile('bar.txt', 'bar contents')168 >>> another_file = SIRPImageFile('bar.txt', 'bar contents') 169 169 170 170 We happen to know, due to the implementation of … … 200 200 --------------------------- 201 201 202 As :class:`waeup.sirp.image. WAeUPImageFile` objects support storing202 As :class:`waeup.sirp.image.SIRPImageFile` objects support storing 203 203 image data by using external 'storages', also our widgets should do 204 204 so. … … 220 220 ... contents = f.read() 221 221 ... id_string = hashlib.md5(contents).hexdigest() 222 ... result = WAeUPImageFile(filename, id_string)222 ... result = SIRPImageFile(filename, id_string) 223 223 ... self.storage[id_string] = contents 224 224 ... return result … … 260 260 We now want to simulate, that the field contains already data, 261 261 identified by some `file_id`. To do so, we first store the data in our 262 file retrieval and then create a WAeUPImageFile object with that262 file retrieval and then create a SIRPImageFile object with that 263 263 file_id stored: 264 264 265 >>> from waeup.sirp.image import create WAeUPImageFile266 >>> image = create WAeUPImageFile(265 >>> from waeup.sirp.image import createSIRPImageFile 266 >>> image = createSIRPImageFile( 267 267 ... 'sample.jpg', open(testimage, 'rb')) 268 268 >>> file_id = image.data … … 274 274 '9feac4265077922000aa8b88748e25be' 275 275 276 The new file was stored by our utility, as create WAeUPImageFile looks276 The new file was stored by our utility, as createSIRPImageFile looks 277 277 up IFileRetrieval utilities and uses them: 278 278 -
main/waeup.sirp/trunk/src/waeup/sirp/image/browser/widget.py
r7196 r7321 19 19 """ 20 20 import os 21 from waeup.sirp.image import WAeUPImageFile21 from waeup.sirp.image import SIRPImageFile 22 22 from hurry.file.browser.widget import ( 23 23 EncodingFileWidget, DownloadWidget, FakeFieldStorage) … … 62 62 seek(0) 63 63 return retrieval.createFile(input.filename, input) 64 return WAeUPImageFile(input.filename, data)64 return SIRPImageFile(input.filename, data) 65 65 else: 66 66 return self.context.missing_value … … 143 143 data = file_id.decode('base64') 144 144 filename, filedata = data.split('\n', 1) 145 return WAeUPImageFile(filename, filedata)145 return SIRPImageFile(filename, filedata) 146 146 147 147 class ThumbnailWidget(DownloadWidget):
Note: See TracChangeset for help on using the changeset viewer.