web/test/data/schema.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 28 Apr 2010 10:06:01 +0200
branchstable
changeset 5421 8167de96c523
parent 4252 6c4f109c2b03
child 5423 e15abfdcce38
child 5424 8ecbcbff9777
permissions -rw-r--r--
proper licensing information (LGPL-2.1). Hope I get it right this time.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    10
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    11
# logilab-common is distributed in the hope that it will be useful, but WITHOUT
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
"""
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
"""
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
                            SubjectRelation, ObjectRelation,
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
                            String, Int, Datetime, Boolean, Float)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
from yams.constraints import IntervalBoundConstraint
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
class Salesterm(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
    described_by_test = SubjectRelation('File', cardinality='1*', composite='subject')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
    amount = Int(constraints=[IntervalBoundConstraint(0, 100)])
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
    reason = String(maxsize=20, vocabulary=[u'canceled', u'sold'])
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
class tags(RelationDefinition):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
    subject = 'Tag'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
    object = ('BlogEntry', 'CWUser')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    35
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
class checked_by(RelationType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
    subject = 'BlogEntry'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
    object = 'CWUser'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    39
    cardinality = '?*'
4078
3704c121624c api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2636
diff changeset
    40
    __permissions__ = {
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    41
        'add': ('managers',),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
        'read': ('managers', 'users'),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
        'delete': ('managers',),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
        }
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    46
class Personne(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    47
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    48
    prenom = String(fulltextindexed=True, maxsize=64)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    49
    sexe   = String(maxsize=1, default='M')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    50
    promo  = String(vocabulary=('bon','pasbon'))
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    51
    titre  = String(fulltextindexed=True, maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    52
    ass    = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    53
    web    = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    54
    tel    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    55
    fax    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
    datenaiss = Datetime()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
    test   = Boolean()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    58
    description = String()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
    salary = Float()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    60
    travaille = SubjectRelation('Societe')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    61
    connait = ObjectRelation('CWUser')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    62
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    63
class Societe(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    64
    nom  = String(maxsize=64, fulltextindexed=True)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    65
    web  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    66
    type  = String(maxsize=128) # attribute in common with Note
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    67
    tel  = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    68
    fax  = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    69
    rncs = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    70
    ad1  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
    ad2  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    72
    ad3  = String(maxsize=128)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    73
    cp   = String(maxsize=12)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    74
    ville= String(maxsize=32)
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75