Ignore:
Timestamp:
8 Mar 2012, 22:28:46 (13 years ago)
Author:
Henrik Bettermann
Message:

KOFA -> Kofa

Location:
main/waeup.kofa/trunk/src/waeup/kofa/image
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/image/README.txt

    r7811 r7819  
    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:`KofaImageFile` object::
     5
     6  >>> from waeup.kofa.image import KofaImageFile
     7  >>> file = KofaImageFile('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 KofaImageFile 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 KofaImageFile 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 = KofaImageFile('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 = KofaImageFile('foo.jpg', 'data')
    105105  >>> f = file.file
    106106  >>> f.read()
     
    141141  Traceback (most recent call last):
    142142  ...
    143   WrongType: ('asd', <class 'waeup.kofa.image.image.KOFAImageFile'>, 'foo')
     143  WrongType: ('asd', <class 'waeup.kofa.image.image.KofaImageFile'>, '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:`KofaImageFile` instances.
     147
     148We can store normal :class:`KofaImageFile` instances:
     149
     150  >>> field.validate(KofaImageFile('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  ...     KofaImageFile('bar.jpg', '123456789012')) is None
     176  True
     177
     178  >>> field.validate(
     179  ...     KofaImageFile('bar.jpg', '12345')) is None
    180180  True
    181181
     
    183183
    184184  >>> field.validate(
    185   ...     KOFAImageFile('bar.jpg', '1234567890123'))
     185  ...     KofaImageFile('bar.jpg', '1234567890123'))
    186186  Traceback (most recent call last):
    187187  ...
     
    189189
    190190  >>> field.validate(
    191   ...     KOFAImageFile('bar.jpg', '1234'))
     191  ...     KofaImageFile('bar.jpg', '1234'))
    192192  Traceback (most recent call last):
    193193  ...
     
    198198----------------------------
    199199
    200 KOFAImageFile does not reproduce the broken unequal comparison from
     200KofaImageFile 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 = KofaImageFile('bar.jpg', '123456789')
     204  >>> f2 = KofaImageFile('bar.jpg', '123456789')
     205  >>> f3 = KofaImageFile('baz.jpg', '1234')
    206206  >>> f1 == f2
    207207  True
  • main/waeup.kofa/trunk/src/waeup/kofa/image/__init__.py

    r7811 r7819  
    33Includings schemas, widgets and the content components.
    44"""
    5 from waeup.kofa.image.image import KOFAImageFile, createKOFAImageFile
     5from waeup.kofa.image.image import KofaImageFile, createKofaImageFile
    66
    77__all__ = [
    8     "KOFAImageFile",
    9     "createKOFAImageFile",
     8    "KofaImageFile",
     9    "createKofaImageFile",
    1010    ]
  • main/waeup.kofa/trunk/src/waeup/kofa/image/browser/tests/image.txt

    r7811 r7819  
    1212
    1313  >>> import os
    14   >>> from waeup.kofa.image import KOFAImageFile
     14  >>> from waeup.kofa.image import KofaImageFile
    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 = KofaImageFile('foo.jpg', open(testimage, 'rb').read())
    1818  >>> some_file.filename
    1919  'foo.jpg'
     
    166166prepare some new file:
    167167
    168   >>> another_file = KOFAImageFile('bar.txt', 'bar contents')
     168  >>> another_file = KofaImageFile('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.kofa.image.KofaImageFile` 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 = KofaImageFile(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 KofaImageFile object with that
    263263file_id stored:
    264264
    265   >>> from waeup.kofa.image import createKOFAImageFile
    266   >>> image = createKOFAImageFile(
     265  >>> from waeup.kofa.image import createKofaImageFile
     266  >>> image = createKofaImageFile(
    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 createKofaImageFile looks
    277277up IFileRetrieval utilities and uses them:
    278278
  • main/waeup.kofa/trunk/src/waeup/kofa/image/browser/widget.py

    r7811 r7819  
    1919"""
    2020import os
    21 from waeup.kofa.image import KOFAImageFile
     21from waeup.kofa.image import KofaImageFile
    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 KofaImageFile(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 KofaImageFile(filename, filedata)
    146146
    147147class ThumbnailWidget(DownloadWidget):
  • main/waeup.kofa/trunk/src/waeup/kofa/image/image.py

    r7811 r7819  
    2323from zope.component import getUtility
    2424from zope.interface import implements
    25 from waeup.kofa.image.interfaces import IKOFAImageFile
     25from waeup.kofa.image.interfaces import IKofaImageFile
    2626
    27 class KOFAImageFile(HurryFile):
     27class KofaImageFile(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:`KofaImageFile` you should use
     35    :func:`createKofaImageFile`.
    3636    """
    37     implements(IKOFAImageFile)
     37    implements(IKofaImageFile)
    3838
    3939    def __ne__(self, other):
     
    4545            return True
    4646
    47 def createKOFAImageFile(filename, f):
     47def createKofaImageFile(filename, f):
    4848    retrieval = getUtility(IFileRetrieval)
    4949    return retrieval.createFile(filename, f)
  • main/waeup.kofa/trunk/src/waeup/kofa/image/interfaces.py

    r7811 r7819  
    2424    """
    2525
    26 class IKOFAImageFile(IHurryFile):
     26class IKofaImageFile(IHurryFile):
    2727    """Image file.
    2828    """
  • main/waeup.kofa/trunk/src/waeup/kofa/image/schema.py

    r7811 r7819  
    2323from hurry.file.schema import File
    2424from waeup.kofa.image.interfaces import IImageFile
    25 from waeup.kofa.image.image import KOFAImageFile
     25from waeup.kofa.image.image import KofaImageFile
    2626
    2727class MinMaxSize(object):
     
    8282    implements(IImageFile)
    8383
    84     _type = KOFAImageFile
     84    _type = KofaImageFile
Note: See TracChangeset for help on using the changeset viewer.