Changeset 7811 for main/waeup.kofa/trunk/src/waeup/kofa/image/README.txt
- Timestamp:
- 8 Mar 2012, 19:00:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/image/README.txt
r7495 r7811 1 waeup. sirp.image -- handling image files1 waeup.kofa.image -- handling image files 2 2 ======================================== 3 3 4 The image file widget is built on top of the :class:` SIRPImageFile` object::5 6 >>> from waeup. sirp.image import SIRPImageFile7 >>> file = SIRPImageFile('foo.jpg', 'mydata')4 The image file widget is built on top of the :class:`KOFAImageFile` object:: 5 6 >>> from waeup.kofa.image import KOFAImageFile 7 >>> file = KOFAImageFile('foo.jpg', 'mydata') 8 8 >>> file.filename 9 9 'foo.jpg' … … 16 16 'mydata' 17 17 18 We can also create SIRPImageFile objects from file-like objects::18 We can also create KOFAImageFile objects from file-like objects:: 19 19 20 20 >>> from StringIO import StringIO … … 36 36 ---------------- 37 37 38 The SIRPImageFile object normally stores the file data using ZODB38 The KOFAImageFile object normally stores the file data using ZODB 39 39 persistence. Files can however also be stored by tramline. If 40 40 tramline is installed in Apache, the Tramline takes care of generating … … 73 73 just '1') will now be created:: 74 74 75 >>> file = SIRPImageFile('foo.jpg', '1')75 >>> file = KOFAImageFile('foo.jpg', '1') 76 76 77 77 The data is now '1', referring to the real file:: … … 102 102 We expect the same behavior as when tramline is not installed:: 103 103 104 >>> file = SIRPImageFile('foo.jpg', 'data')104 >>> file = KOFAImageFile('foo.jpg', 'data') 105 105 >>> f = file.file 106 106 >>> f.read() … … 114 114 >>> shutil.rmtree(dirpath) 115 115 116 Support for :mod:`waeup. sirp.imagestorage`116 Support for :mod:`waeup.kofa.imagestorage` 117 117 ------------------------------------------ 118 118 119 119 The behaviour shown above can be used for any Zope3 application. With 120 :mod:`waeup. sirp` we use a special file retrieval utility defined in121 :mod:`waeup. sirp.imagestorage`. As this utility is based on122 :mod:`waeup. sirp` internal stuff we do not show it here but in the120 :mod:`waeup.kofa` we use a special file retrieval utility defined in 121 :mod:`waeup.kofa.imagestorage`. As this utility is based on 122 :mod:`waeup.kofa` internal stuff we do not show it here but in the 123 123 tests that come with that storage type. 124 124 … … 135 135 The `ImageFile` field accepts only certain content types: 136 136 137 >>> from waeup. sirp.image.schema import ImageFile137 >>> from waeup.kofa.image.schema import ImageFile 138 138 >>> from zope.publisher.browser import TestRequest 139 139 >>> field = ImageFile(__name__='foo', title=u'Foo') … … 141 141 Traceback (most recent call last): 142 142 ... 143 WrongType: ('asd', <class 'waeup. sirp.image.image.SIRPImageFile'>, 'foo')143 WrongType: ('asd', <class 'waeup.kofa.image.image.KOFAImageFile'>, 'foo') 144 144 145 145 which means: `ImageFile` fields should better contain 146 :class:` SIRPImageFile` instances.147 148 We can store normal :class:` SIRPImageFile` instances:149 150 >>> field.validate( SIRPImageFile('bar.jpg', 'data')) is None146 :class:`KOFAImageFile` instances. 147 148 We can store normal :class:`KOFAImageFile` instances: 149 150 >>> field.validate(KOFAImageFile('bar.jpg', 'data')) is None 151 151 True 152 152 … … 173 173 174 174 >>> field.validate( 175 ... SIRPImageFile('bar.jpg', '123456789012')) is None176 True 177 178 >>> field.validate( 179 ... SIRPImageFile('bar.jpg', '12345')) is None175 ... KOFAImageFile('bar.jpg', '123456789012')) is None 176 True 177 178 >>> field.validate( 179 ... KOFAImageFile('bar.jpg', '12345')) is None 180 180 True 181 181 … … 183 183 184 184 >>> field.validate( 185 ... SIRPImageFile('bar.jpg', '1234567890123'))185 ... KOFAImageFile('bar.jpg', '1234567890123')) 186 186 Traceback (most recent call last): 187 187 ... … … 189 189 190 190 >>> field.validate( 191 ... SIRPImageFile('bar.jpg', '1234'))191 ... KOFAImageFile('bar.jpg', '1234')) 192 192 Traceback (most recent call last): 193 193 ... … … 198 198 ---------------------------- 199 199 200 SIRPImageFile does not reproduce the broken unequal comparison from200 KOFAImageFile does not reproduce the broken unequal comparison from 201 201 its base: 202 202 203 >>> f1 = SIRPImageFile('bar.jpg', '123456789')204 >>> f2 = SIRPImageFile('bar.jpg', '123456789')205 >>> f3 = SIRPImageFile('baz.jpg', '1234')203 >>> f1 = KOFAImageFile('bar.jpg', '123456789') 204 >>> f2 = KOFAImageFile('bar.jpg', '123456789') 205 >>> f3 = KOFAImageFile('baz.jpg', '1234') 206 206 >>> f1 == f2 207 207 True
Note: See TracChangeset for help on using the changeset viewer.