Ignore:
Timestamp:
13 Nov 2014, 14:40:27 (10 years ago)
Author:
Henrik Bettermann
Message:

Change of name.

Location:
main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba
Files:
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/README.txt

    r7819 r11949  
    1 waeup.kofa.image -- handling image files
     1waeup.ikoba.image -- handling image files
    22========================================
    33
    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')
     4The image file widget is built on top of the :class:`IkobaImageFile` object::
     5
     6  >>> from waeup.ikoba.image import IkobaImageFile
     7  >>> file = IkobaImageFile('foo.jpg', 'mydata')
    88  >>> file.filename
    99  'foo.jpg'
     
    1616  'mydata'
    1717
    18 We can also create KofaImageFile objects from file-like objects::
     18We can also create IkobaImageFile objects from file-like objects::
    1919
    2020  >>> from StringIO import StringIO
     
    3636----------------
    3737
    38 The KofaImageFile object normally stores the file data using ZODB
     38The IkobaImageFile object normally stores the file data using ZODB
    3939persistence. Files can however also be stored by tramline.  If
    4040tramline is installed in Apache, the Tramline takes care of generating
     
    7373just '1') will now be created::
    7474
    75   >>> file = KofaImageFile('foo.jpg', '1')
     75  >>> file = IkobaImageFile('foo.jpg', '1')
    7676
    7777The data is now '1', referring to the real file::
     
    102102We expect the same behavior as when tramline is not installed::
    103103
    104   >>> file = KofaImageFile('foo.jpg', 'data')
     104  >>> file = IkobaImageFile('foo.jpg', 'data')
    105105  >>> f = file.file
    106106  >>> f.read()
     
    114114  >>> shutil.rmtree(dirpath)
    115115
    116 Support for :mod:`waeup.kofa.imagestorage`
     116Support for :mod:`waeup.ikoba.imagestorage`
    117117------------------------------------------
    118118
    119119The behaviour shown above can be used for any Zope3 application. With
    120 :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
     120:mod:`waeup.ikoba` we use a special file retrieval utility defined in
     121:mod:`waeup.ikoba.imagestorage`. As this utility is based on
     122:mod:`waeup.ikoba` internal stuff we do not show it here but in the
    123123tests that come with that storage type.
    124124
     
    135135The `ImageFile` field accepts only certain content types:
    136136
    137   >>> from waeup.kofa.image.schema import ImageFile
     137  >>> from waeup.ikoba.image.schema import ImageFile
    138138  >>> from zope.publisher.browser import TestRequest
    139139  >>> field = ImageFile(__name__='foo', title=u'Foo')
     
    141141  Traceback (most recent call last):
    142142  ...
    143   WrongType: ('asd', <class 'waeup.kofa.image.image.KofaImageFile'>, 'foo')
     143  WrongType: ('asd', <class 'waeup.ikoba.image.image.IkobaImageFile'>, 'foo')
    144144
    145145which means: `ImageFile` fields should better contain
    146 :class:`KofaImageFile` instances.
    147 
    148 We can store normal :class:`KofaImageFile` instances:
    149 
    150   >>> field.validate(KofaImageFile('bar.jpg', 'data')) is None
     146:class:`IkobaImageFile` instances.
     147
     148We can store normal :class:`IkobaImageFile` instances:
     149
     150  >>> field.validate(IkobaImageFile('bar.jpg', 'data')) is None
    151151  True
    152152
     
    173173
    174174  >>> field.validate(
    175   ...     KofaImageFile('bar.jpg', '123456789012')) is None
    176   True
    177 
    178   >>> field.validate(
    179   ...     KofaImageFile('bar.jpg', '12345')) is None
     175  ...     IkobaImageFile('bar.jpg', '123456789012')) is None
     176  True
     177
     178  >>> field.validate(
     179  ...     IkobaImageFile('bar.jpg', '12345')) is None
    180180  True
    181181
     
    183183
    184184  >>> field.validate(
    185   ...     KofaImageFile('bar.jpg', '1234567890123'))
     185  ...     IkobaImageFile('bar.jpg', '1234567890123'))
    186186  Traceback (most recent call last):
    187187  ...
     
    189189
    190190  >>> field.validate(
    191   ...     KofaImageFile('bar.jpg', '1234'))
     191  ...     IkobaImageFile('bar.jpg', '1234'))
    192192  Traceback (most recent call last):
    193193  ...
     
    198198----------------------------
    199199
    200 KofaImageFile does not reproduce the broken unequal comparison from
     200IkobaImageFile does not reproduce the broken unequal comparison from
    201201its base:
    202202
    203   >>> f1 = KofaImageFile('bar.jpg', '123456789')
    204   >>> f2 = KofaImageFile('bar.jpg', '123456789')
    205   >>> f3 = KofaImageFile('baz.jpg', '1234')
     203  >>> f1 = IkobaImageFile('bar.jpg', '123456789')
     204  >>> f2 = IkobaImageFile('bar.jpg', '123456789')
     205  >>> f3 = IkobaImageFile('baz.jpg', '1234')
    206206  >>> f1 == f2
    207207  True
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/__init__.py

    r11480 r11949  
    33Including schemas, widgets and the content components.
    44"""
    5 from waeup.kofa.image.image import KofaImageFile, createKofaImageFile
     5from waeup.ikoba.image.image import IkobaImageFile, createIkobaImageFile
    66
    77__all__ = [
    8     "KofaImageFile",
    9     "createKofaImageFile",
     8    "IkobaImageFile",
     9    "createIkobaImageFile",
    1010    ]
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/__init__.py

    r7811 r11949  
    11# The public API part
    22# Contains the widgets defined for image files.
    3 from waeup.kofa.image.browser.widget import (
     3from waeup.ikoba.image.browser.widget import (
    44    EncodingImageFileWidget, ThumbnailWidget,
    55    )
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/tests/image.txt

    r7819 r11949  
    1212
    1313  >>> import os
    14   >>> from waeup.kofa.image import KofaImageFile
     14  >>> from waeup.ikoba.image import IkobaImageFile
    1515  >>> testimage = os.path.join(os.path.dirname(__file__), 'sample.jpg')
    1616  >>> 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())
    1818  >>> some_file.filename
    1919  'foo.jpg'
     
    2626  >>> from hurry.file.browser import DownloadWidget
    2727  >>> from hurry.file.schema import File
    28   >>> from waeup.kofa.image.schema import ImageFile
     28  >>> from waeup.ikoba.image.schema import ImageFile
    2929  >>> from zope.publisher.browser import TestRequest
    3030  >>> field = ImageFile(__name__='foo', title=u'Foo')
     
    5151Instead of downloading, we can also use a thumbnail widget:
    5252
    53   >>> from waeup.kofa.image.browser import ThumbnailWidget
     53  >>> from waeup.ikoba.image.browser import ThumbnailWidget
    5454  >>> request = TestRequest(form={'field.foo': FileUpload(some_file)})
    5555  >>> widget = ThumbnailWidget(field, request)
     
    6161data already available, and no data in request:
    6262
    63   >>> from waeup.kofa.image.browser import EncodingImageFileWidget
     63  >>> from waeup.ikoba.image.browser import EncodingImageFileWidget
    6464  >>> field = ImageFile(__name__='foo', title=u'Foo', required=False)
    6565  >>> field = field.bind(None)
     
    166166prepare some new file:
    167167
    168   >>> another_file = KofaImageFile('bar.txt', 'bar contents')
     168  >>> another_file = IkobaImageFile('bar.txt', 'bar contents')
    169169
    170170We happen to know, due to the implementation of
     
    200200---------------------------
    201201
    202 As :class:`waeup.kofa.image.KofaImageFile` objects support storing
     202As :class:`waeup.ikoba.image.IkobaImageFile` objects support storing
    203203image data by using external 'storages', also our widgets should do
    204204so.
     
    220220  ...         contents = f.read()
    221221  ...         id_string = hashlib.md5(contents).hexdigest()
    222   ...         result = KofaImageFile(filename, id_string)
     222  ...         result = IkobaImageFile(filename, id_string)
    223223  ...         self.storage[id_string] = contents
    224224  ...         return result
     
    260260We now want to simulate, that the field contains already data,
    261261identified by some `file_id`. To do so, we first store the data in our
    262 file retrieval and then create a KofaImageFile object with that
     262file retrieval and then create a IkobaImageFile object with that
    263263file_id stored:
    264264
    265   >>> from waeup.kofa.image import createKofaImageFile
    266   >>> image = createKofaImageFile(
     265  >>> from waeup.ikoba.image import createIkobaImageFile
     266  >>> image = createIkobaImageFile(
    267267  ...     'sample.jpg', open(testimage, 'rb'))
    268268  >>> file_id = image.data
     
    274274  '9feac4265077922000aa8b88748e25be'
    275275
    276 The new file was stored by our utility, as createKofaImageFile looks
     276The new file was stored by our utility, as createIkobaImageFile looks
    277277up IFileRetrieval utilities and uses them:
    278278
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/tests/test_views.py

    r7811 r11949  
    3030from hurry.file.file import IdFileRetrieval
    3131from hurry.file.interfaces import IFileRetrieval
    32 from waeup.kofa.image.browser.views import HurryFileView
     32from waeup.ikoba.image.browser.views import HurryFileView
    3333from zope.component import getMultiAdapter, provideUtility
    3434from zope.publisher.browser import TestRequest
     
    4141class ImageBrowserViewsLayer(object):
    4242    """A layer that registers all components in
    43        `waeup.kofa.image.browser.views` module.
     43       `waeup.ikoba.image.browser.views` module.
    4444    """
    4545    @classmethod
    4646    def setUp(cls):
    47         grok.testing.grok('waeup.kofa.image.browser.views')
     47        grok.testing.grok('waeup.ikoba.image.browser.views')
    4848
    4949    @classmethod
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/browser/widget.py

    r7819 r11949  
    1919"""
    2020import os
    21 from waeup.kofa.image import KofaImageFile
     21from waeup.ikoba.image import IkobaImageFile
    2222from hurry.file.browser.widget import (
    2323    EncodingFileWidget, DownloadWidget, FakeFieldStorage)
     
    6262                seek(0)
    6363                return retrieval.createFile(input.filename, input)
    64             return KofaImageFile(input.filename, data)
     64            return IkobaImageFile(input.filename, data)
    6565        else:
    6666            return self.context.missing_value
     
    143143        data = file_id.decode('base64')
    144144        filename, filedata = data.split('\n', 1)
    145         return KofaImageFile(filename, filedata)
     145        return IkobaImageFile(filename, filedata)
    146146
    147147class ThumbnailWidget(DownloadWidget):
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/image.py

    r7819 r11949  
    2323from zope.component import getUtility
    2424from zope.interface import implements
    25 from waeup.kofa.image.interfaces import IKofaImageFile
     25from waeup.ikoba.image.interfaces import IIkobaImageFile
    2626
    27 class KofaImageFile(HurryFile):
     27class IkobaImageFile(HurryFile):
    2828    """A file prepared for storing image files.
    2929
     
    3232    regular hurry files.
    3333
    34     To create a :class:`KofaImageFile` you should use
    35     :func:`createKofaImageFile`.
     34    To create a :class:`IkobaImageFile` you should use
     35    :func:`createIkobaImageFile`.
    3636    """
    37     implements(IKofaImageFile)
     37    implements(IIkobaImageFile)
    3838
    3939    def __ne__(self, other):
     
    4545            return True
    4646
    47 def createKofaImageFile(filename, f):
     47def createIkobaImageFile(filename, f):
    4848    retrieval = getUtility(IFileRetrieval)
    4949    return retrieval.createFile(filename, f)
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/interfaces.py

    r7819 r11949  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
    18 """Interfaces for waeup.kofa.image
     18"""Interfaces for waeup.ikoba.image
    1919"""
    2020from hurry.file.interfaces import IFile, IFileRetrieval, IHurryFile
     
    2424    """
    2525
    26 class IKofaImageFile(IHurryFile):
     26class IIkobaImageFile(IHurryFile):
    2727    """Image file.
    2828    """
  • main/waeup.kofa/branches/henrik-regista/src/waeup/ikoba/image/schema.py

    r7819 r11949  
    2222from zope.schema.interfaces import TooBig, TooSmall
    2323from hurry.file.schema import File
    24 from waeup.kofa.image.interfaces import IImageFile
    25 from waeup.kofa.image.image import KofaImageFile
     24from waeup.ikoba.image.interfaces import IImageFile
     25from waeup.ikoba.image.image import IkobaImageFile
    2626
    2727class MinMaxSize(object):
     
    8282    implements(IImageFile)
    8383
    84     _type = KofaImageFile
     84    _type = IkobaImageFile
Note: See TracChangeset for help on using the changeset viewer.