web/test/data/schema.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 19 Feb 2010 09:34:14 +0100
branchstable
changeset 4643 921737d2e3a8
parent 4252 6c4f109c2b03
child 5386 4c92202ab130
child 5421 8167de96c523
permissions -rw-r--r--
fix optimisation with super session that may lead to integrity loss at some point I've decided to stop ensuring ?1 cardinality was respected when adding a new relation using a super session, to avoid the cost of the delete query. That was yet discussable because it introduced unexpected difference between execute and unsafe_execute, which is imo not worth it. Also, now that rql() in migration script default to unsafe_execute, we definitly don't want that implicit behaviour change (which already cause bug when for instance adding another default workflow for an entity type: without that fix we end up with *two* default workflows while the schema tells we can have only one. IMO we should go to the direction that super session skip all security check, but nothing else, unless explicitly asked.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
"""
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
:organization: Logilab
4212
ab6573088b4a update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2636
diff changeset
     4
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
"""
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
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
    10
                            SubjectRelation, ObjectRelation,
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
                            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
    12
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
    13
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
class Salesterm(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
    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
    16
    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
    17
    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
    18
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
class tags(RelationDefinition):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
    subject = 'Tag'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
    object = ('BlogEntry', 'CWUser')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
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
    24
    subject = 'BlogEntry'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
    object = 'CWUser'
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
    cardinality = '?*'
4078
3704c121624c api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2636
diff changeset
    27
    __permissions__ = {
2636
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    28
        'add': ('managers',),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
        'read': ('managers', 'users'),
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
        'delete': ('managers',),
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
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
class Personne(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
    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
    35
    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
    36
    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
    37
    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
    38
    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
    39
    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
    40
    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
    41
    tel    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
    fax    = Int()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
    datenaiss = Datetime()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    44
    test   = Boolean()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
    description = String()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    46
    salary = Float()
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    47
    travaille = SubjectRelation('Societe')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    48
    connait = ObjectRelation('CWUser')
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    49
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    50
class Societe(EntityType):
104291d9bd00 R [web test] rewrite schema with a single python module
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    51
    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
    52
    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
    53
    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
    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
    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
    57
    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
    58
    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
    59
    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
    60
    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
    61
    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
    62