Changeset 11949 for main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/tests/image.txt
- Timestamp:
- 13 Nov 2014, 14:40:27 (10 years ago)
- Location:
- main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/tests/image.txt
r7819 r11949 12 12 13 13 >>> import os 14 >>> from waeup. kofa.image import KofaImageFile14 >>> from waeup.ikoba.image import IkobaImageFile 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 = KofaImageFile('foo.jpg', open(testimage, 'rb').read())17 >>> some_file = IkobaImageFile('foo.jpg', open(testimage, 'rb').read()) 18 18 >>> some_file.filename 19 19 'foo.jpg' … … 26 26 >>> from hurry.file.browser import DownloadWidget 27 27 >>> from hurry.file.schema import File 28 >>> from waeup. kofa.image.schema import ImageFile28 >>> from waeup.ikoba.image.schema import ImageFile 29 29 >>> from zope.publisher.browser import TestRequest 30 30 >>> field = ImageFile(__name__='foo', title=u'Foo') … … 51 51 Instead of downloading, we can also use a thumbnail widget: 52 52 53 >>> from waeup. kofa.image.browser import ThumbnailWidget53 >>> from waeup.ikoba.image.browser import ThumbnailWidget 54 54 >>> request = TestRequest(form={'field.foo': FileUpload(some_file)}) 55 55 >>> widget = ThumbnailWidget(field, request) … … 61 61 data already available, and no data in request: 62 62 63 >>> from waeup. kofa.image.browser import EncodingImageFileWidget63 >>> from waeup.ikoba.image.browser import EncodingImageFileWidget 64 64 >>> field = ImageFile(__name__='foo', title=u'Foo', required=False) 65 65 >>> field = field.bind(None) … … 166 166 prepare some new file: 167 167 168 >>> another_file = KofaImageFile('bar.txt', 'bar contents')168 >>> another_file = IkobaImageFile('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.KofaImageFile` objects support storing202 As :class:`waeup.ikoba.image.IkobaImageFile` 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 = KofaImageFile(filename, id_string)222 ... result = IkobaImageFile(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 KofaImageFile object with that262 file retrieval and then create a IkobaImageFile object with that 263 263 file_id stored: 264 264 265 >>> from waeup. kofa.image import createKofaImageFile266 >>> image = create KofaImageFile(265 >>> from waeup.ikoba.image import createIkobaImageFile 266 >>> image = createIkobaImageFile( 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 KofaImageFile looks276 The new file was stored by our utility, as createIkobaImageFile looks 277 277 up IFileRetrieval utilities and uses them: 278 278
Note: See TracChangeset for help on using the changeset viewer.