cubicweb/server/test/data-migractions/cubicweb_file/schema.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Wed, 24 Jul 2019 16:52:00 +0200
changeset 12711 9d72e299309e
parent 12515 cubicweb/server/test/data/cubicweb_file/schema.py@2d43c8b30ef0
permissions -rw-r--r--
[test] Replace symlinks by real copies This solves a "python setup.py build" issue.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12515
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     1
from yams.buildobjs import EntityType, String, Bytes, RichString
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     2
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     3
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     4
class File(EntityType):
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     5
    """a downloadable file which may contains binary data"""
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     6
    title = String(fulltextindexed=True, maxsize=256)
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     7
    data = Bytes(required=True, description='file to upload')
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     8
    data_format = String(
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
     9
        required=True, maxsize=128,
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    10
        description=('MIME type of the file. Should be dynamically set '
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    11
                     'at upload time.'))
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    12
    data_encoding = String(
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    13
        maxsize=32,
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    14
        description=('encoding of the file when it applies (e.g. text). '
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    15
                     'Should be dynamically set at upload time.'))
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    16
    data_name = String(
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    17
        required=True, fulltextindexed=True,
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    18
        description=('name of the file. Should be dynamically set '
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    19
                     'at upload time.'))
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    20
    data_hash = String(
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    21
        maxsize=256,  # max len of currently available hash alg + prefix is 140
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    22
        description=('hash of the file. May be set at upload time.'),
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    23
        __permissions__={'read': ('managers', 'users', 'guests'),
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    24
                         'add': (),
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    25
                         'update': ()})
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    26
    description = RichString(fulltextindexed=True, internationalizable=True,
2d43c8b30ef0 [server/test] do not depend on third party cubes
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
diff changeset
    27
                             default_format='text/rest')