Changeset 7819 for main/waeup.kofa/trunk/src/waeup/kofa/image/browser/tests
- Timestamp:
- 8 Mar 2012, 22:28:46 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/image/browser/tests/image.txt
r7811 r7819 12 12 13 13 >>> import os 14 >>> from waeup.kofa.image import K OFAImageFile14 >>> from waeup.kofa.image import KofaImageFile 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 = K OFAImageFile('foo.jpg', open(testimage, 'rb').read())17 >>> some_file = KofaImageFile('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 = K OFAImageFile('bar.txt', 'bar contents')168 >>> another_file = KofaImageFile('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.kofa.image.K OFAImageFile` objects support storing202 As :class:`waeup.kofa.image.KofaImageFile` 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 = K OFAImageFile(filename, id_string)222 ... result = KofaImageFile(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 K OFAImageFile object with that262 file retrieval and then create a KofaImageFile object with that 263 263 file_id stored: 264 264 265 >>> from waeup.kofa.image import createK OFAImageFile266 >>> image = createK OFAImageFile(265 >>> from waeup.kofa.image import createKofaImageFile 266 >>> image = createKofaImageFile( 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 createK OFAImageFile looks276 The new file was stored by our utility, as createKofaImageFile looks 277 277 up IFileRetrieval utilities and uses them: 278 278
Note: See TracChangeset for help on using the changeset viewer.