- Timestamp:
- 13 Nov 2014, 14:40:27 (10 years ago)
- Location:
- main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/__init__.py
r7811 r11949 1 1 # The public API part 2 2 # Contains the widgets defined for image files. 3 from waeup. kofa.image.browser.widget import (3 from waeup.ikoba.image.browser.widget import ( 4 4 EncodingImageFileWidget, ThumbnailWidget, 5 5 ) -
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 -
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/tests/test_views.py
r7811 r11949 30 30 from hurry.file.file import IdFileRetrieval 31 31 from hurry.file.interfaces import IFileRetrieval 32 from waeup. kofa.image.browser.views import HurryFileView32 from waeup.ikoba.image.browser.views import HurryFileView 33 33 from zope.component import getMultiAdapter, provideUtility 34 34 from zope.publisher.browser import TestRequest … … 41 41 class ImageBrowserViewsLayer(object): 42 42 """A layer that registers all components in 43 `waeup. kofa.image.browser.views` module.43 `waeup.ikoba.image.browser.views` module. 44 44 """ 45 45 @classmethod 46 46 def setUp(cls): 47 grok.testing.grok('waeup. kofa.image.browser.views')47 grok.testing.grok('waeup.ikoba.image.browser.views') 48 48 49 49 @classmethod -
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/widget.py
r7819 r11949 19 19 """ 20 20 import os 21 from waeup. kofa.image import KofaImageFile21 from waeup.ikoba.image import IkobaImageFile 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 KofaImageFile(input.filename, data)64 return IkobaImageFile(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 KofaImageFile(filename, filedata)145 return IkobaImageFile(filename, filedata) 146 146 147 147 class ThumbnailWidget(DownloadWidget):
Note: See TracChangeset for help on using the changeset viewer.