server/test/data/schema.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 06 Jun 2011 15:17:55 +0200
changeset 7456 c54038622fc9
parent 7252 adb1673efa5f
child 7694 bd56a29acaa8
permissions -rw-r--r--
[datafeed] use a boolean flag on CWSource to ensure we don't have concurrent synchronizations. Closes #1725690
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6279
diff changeset
     1
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
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: 4635
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: 4635
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: 4635
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: 4635
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: 4635
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: 4635
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: 4635
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: 4635
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
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: 4635
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: 4635
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: 4635
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: 4635
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: 4635
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
2503
c4bf7ef8b851 explicit imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
    19
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
6081
ede33e6400ab [forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5762
diff changeset
    20
                            SubjectRelation, RichString, String, Int, Float,
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6279
diff changeset
    21
                            Boolean, Datetime, TZDatetime)
2503
c4bf7ef8b851 explicit imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
    22
from yams.constraints import SizeConstraint
6236
9138f23ee263 [repo tests] add test case for RQLUniqueConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6208
diff changeset
    23
from cubicweb.schema import (WorkflowableEntityType,
9138f23ee263 [repo tests] add test case for RQLUniqueConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6208
diff changeset
    24
                             RQLConstraint, RQLUniqueConstraint,
2503
c4bf7ef8b851 explicit imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
    25
                             ERQLExpression, RRQLExpression)
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
class Affaire(WorkflowableEntityType):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
    28
    __permissions__ = {
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    29
        'read':   ('managers',
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    30
                   ERQLExpression('X owned_by U'), ERQLExpression('X concerne S?, S owned_by U')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    31
        'add':    ('managers', ERQLExpression('X concerne S, S owned_by U')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    32
        'update': ('managers', 'owners', ERQLExpression('X in_state S, S name in ("pitetre", "en cours")')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    33
        'delete': ('managers', 'owners', ERQLExpression('X concerne S, S owned_by U')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    34
        }
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    35
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    36
    ref = String(fulltextindexed=True, indexed=True,
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    37
                 constraints=[SizeConstraint(16)])
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    38
    sujet = String(fulltextindexed=True,
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    39
                   constraints=[SizeConstraint(256)])
2459
d088d0ff48a1 move RichString and co to yams, keeping only a small monkeypatch for cw-page-template here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2455
diff changeset
    40
    descr = RichString(fulltextindexed=True,
d088d0ff48a1 move RichString and co to yams, keeping only a small monkeypatch for cw-page-template here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2455
diff changeset
    41
                       description=_('more detailed description'))
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    42
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    43
    duration = Int()
6081
ede33e6400ab [forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 5762
diff changeset
    44
    invoiced = Float()
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    45
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    46
    depends_on = SubjectRelation('Affaire')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    47
    require_permission = SubjectRelation('CWPermission')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    48
    concerne = SubjectRelation(('Societe', 'Note'))
2923
b97a0f8dd4dc fix test schema and update some tests to work again with wf changes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2920
diff changeset
    49
    todo_by = SubjectRelation('Personne', cardinality='?*')
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    50
    documented_by = SubjectRelation('Card')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    51
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    52
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    53
class Societe(EntityType):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
    54
    __permissions__ = {
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    55
        'read': ('managers', 'users', 'guests'),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    56
        'update': ('managers', 'owners', ERQLExpression('U login L, X nom L')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    57
        'delete': ('managers', 'owners', ERQLExpression('U login L, X nom L')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    58
        'add': ('managers', 'users',)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    59
        }
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    60
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    61
    nom  = String(maxsize=64, fulltextindexed=True)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    62
    web  = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    63
    type  = String(maxsize=128) # attribute in common with Note
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    64
    tel  = Int()
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    65
    fax  = Int()
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    66
    rncs = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    67
    ad1  = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    68
    ad2  = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    69
    ad3  = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    70
    cp   = String(maxsize=12)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    71
    ville= String(maxsize=32)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    72
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    73
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    74
class Division(Societe):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    75
    __specializes_schema__ = True
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    76
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    77
class SubDivision(Division):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    78
    __specializes_schema__ = True
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    79
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    80
class travaille_subdivision(RelationDefinition):
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    81
    subject = 'Personne'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    82
    object = 'SubDivision'
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    83
2455
5346d9f3d5ec [tests] fixes (including two operations renaming)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2349
diff changeset
    84
from cubicweb.schemas.base import CWUser
5346d9f3d5ec [tests] fixes (including two operations renaming)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2349
diff changeset
    85
CWUser.get_relations('login').next().fulltextindexed = True
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    86
2920
64322aa83a1d start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2608
diff changeset
    87
class Note(WorkflowableEntityType):
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    88
    date = String(maxsize=10)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    89
    type = String(maxsize=6)
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    90
    para = String(maxsize=512,
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    91
                  __permissions__ = {
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    92
                      'read':   ('managers', 'users', 'guests'),
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    93
                      'update': ('managers', ERQLExpression('X in_state S, S name "todo"')),
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
    94
                      })
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    95
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    96
    migrated_from = SubjectRelation('Note')
5575
8a531340c3ef no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
    97
    attachment = SubjectRelation('File')
6236
9138f23ee263 [repo tests] add test case for RQLUniqueConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6208
diff changeset
    98
    inline1 = SubjectRelation('Affaire', inlined=True, cardinality='?*',
9138f23ee263 [repo tests] add test case for RQLUniqueConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6208
diff changeset
    99
                              constraints=[RQLUniqueConstraint('S type T, S inline1 A1, A1 todo_by C, '
9138f23ee263 [repo tests] add test case for RQLUniqueConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6208
diff changeset
   100
                                                              'Y type T, Y inline1 A2, A2 todo_by C',
9138f23ee263 [repo tests] add test case for RQLUniqueConstraint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6208
diff changeset
   101
                                                               'S,Y')])
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   102
    todo_by = SubjectRelation('CWUser')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   103
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   104
class Personne(EntityType):
6208
07b176640a8c unique_together integration in CW (alf+syt)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 5762
diff changeset
   105
    __unique_together__ = [('nom', 'prenom', 'inline2')]
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   106
    nom    = String(fulltextindexed=True, required=True, maxsize=64)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   107
    prenom = String(fulltextindexed=True, maxsize=64)
3546
f0aecddf367e fix bug when renaming a full text indexed attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2923
diff changeset
   108
    sexe   = String(maxsize=1, default='M', fulltextindexed=True)
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   109
    promo  = String(vocabulary=('bon','pasbon'))
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   110
    titre  = String(fulltextindexed=True, maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   111
    adel   = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   112
    ass    = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   113
    web    = String(maxsize=128)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   114
    tel    = Int()
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   115
    fax    = Int()
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   116
    datenaiss = Datetime()
7166
dde161937d3e [time zone] support for TZDatetime and TZTime data type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6279
diff changeset
   117
    tzdatenaiss = TZDatetime()
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   118
    test   = Boolean(__permissions__={
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   119
        'read': ('managers', 'users', 'guests'),
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   120
        'update': ('managers',),
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   121
        })
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   122
    description = String()
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   123
    firstname = String(fulltextindexed=True, maxsize=64)
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   124
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   125
    concerne = SubjectRelation('Affaire')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   126
    connait = SubjectRelation('Personne')
2608
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   127
    inline2 = SubjectRelation('Affaire', inlined=True, cardinality='?*')
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   128
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   129
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   130
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   131
class connait(RelationType):
4467
0e73d299730a fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
   132
    symmetric = True
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   133
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   134
class concerne(RelationType):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
   135
    __permissions__ = {
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   136
        'read':   ('managers', 'users', 'guests'),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   137
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   138
        'delete': ('managers', RRQLExpression('O owned_by U')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   139
        }
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   140
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   141
class travaille(RelationDefinition):
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
   142
    __permissions__ = {
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   143
        'read':   ('managers', 'users', 'guests'),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   144
        'add':    ('managers', RRQLExpression('U has_update_permission S')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   145
        'delete': ('managers', RRQLExpression('O owned_by U')),
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   146
        }
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   147
    subject = 'Personne'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   148
    object = 'Societe'
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   149
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   150
class comments(RelationDefinition):
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   151
    subject = 'Comment'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   152
    object = 'Personne'
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   153
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   154
class fiche(RelationDefinition):
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   155
    inlined = True
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   156
    subject = 'Personne'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   157
    object = 'Card'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   158
    cardinality = '??'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   159
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   160
class multisource_inlined_rel(RelationDefinition):
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   161
    inlined = True
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   162
    cardinality = '?*'
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   163
    subject = ('Card', 'Note')
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   164
    object = ('Affaire', 'Note')
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   165
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   166
class multisource_rel(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   167
    subject = ('Card', 'Note')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   168
    object = 'Note'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   169
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   170
class multisource_crossed_rel(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   171
    subject = ('Card', 'Note')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   172
    object = 'Note'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   173
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   174
2608
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   175
class see_also_1(RelationDefinition):
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   176
    name = 'see_also'
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   177
    subject = object = 'Folder'
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   178
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   179
class see_also_2(RelationDefinition):
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   180
    name = 'see_also'
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   181
    subject = ('Bookmark', 'Note')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   182
    object = ('Bookmark', 'Note')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   183
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   184
class evaluee(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   185
    subject = ('Personne', 'CWUser', 'Societe')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   186
    object = ('Note')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   187
5386
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   188
class ecrit_par(RelationType):
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   189
    inlined = True
4c92202ab130 [test] stop using ObjectRelation in schema
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4635
diff changeset
   190
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   191
class ecrit_par_1(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   192
    name = 'ecrit_par'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   193
    subject = 'Note'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   194
    object ='Personne'
3981
8029019884af this invalid constraint now fails with new constraints checking
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3546
diff changeset
   195
    constraints = [RQLConstraint('E concerns P, S version_of P')]
2608
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   196
    cardinality = '?*'
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   197
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   198
class ecrit_par_2(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   199
    name = 'ecrit_par'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   200
    subject = 'Note'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   201
    object ='CWUser'
2608
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   202
    cardinality='?*'
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   203
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   204
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   205
class copain(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   206
    subject = object = 'CWUser'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   207
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   208
class tags(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   209
    subject = 'Tag'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   210
    object = ('CWUser', 'CWGroup', 'State', 'Note', 'Card', 'Affaire')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   211
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   212
class filed_under(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   213
    subject = ('Note', 'Affaire')
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   214
    object = 'Folder'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   215
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   216
class require_permission(RelationDefinition):
2608
21856eda34f6 [F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2503
diff changeset
   217
    subject = ('Card', 'Note', 'Personne')
2349
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   218
    object = 'CWPermission'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   219
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   220
class require_state(RelationDefinition):
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   221
    subject = 'CWPermission'
b9e2c1b7b873 rewrite test schema using a single schema file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
   222
    object = 'State'
7236
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   223
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   224
class personne_composite(RelationDefinition):
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   225
    subject='Personne'
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   226
    object='Personne'
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   227
    composite='subject'
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   228
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   229
class personne_inlined(RelationDefinition):
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   230
    subject='Personne'
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   231
    object='Personne'
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   232
    cardinality='?*'
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   233
    inlined=True
b91205ada414 added test case to monitor speed improvements in the repository code.
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7166
diff changeset
   234
7238
576abb8c4626 fix implementation of repository.glob_add_relations (closes ##1625257)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7236
diff changeset
   235
576abb8c4626 fix implementation of repository.glob_add_relations (closes ##1625257)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7236
diff changeset
   236
class login_user(RelationDefinition):
576abb8c4626 fix implementation of repository.glob_add_relations (closes ##1625257)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7236
diff changeset
   237
    subject = 'Personne'
576abb8c4626 fix implementation of repository.glob_add_relations (closes ##1625257)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7236
diff changeset
   238
    object = 'CWUser'
576abb8c4626 fix implementation of repository.glob_add_relations (closes ##1625257)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents: 7236
diff changeset
   239
    cardinality = '??'
7252
adb1673efa5f [sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7238
diff changeset
   240
adb1673efa5f [sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7238
diff changeset
   241
class ambiguous_inlined(RelationDefinition):
adb1673efa5f [sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7238
diff changeset
   242
    subject = ('Affaire', 'Note')
adb1673efa5f [sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7238
diff changeset
   243
    object = 'CWUser'
adb1673efa5f [sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7238
diff changeset
   244
    inlined = True
adb1673efa5f [sql generation] fix crash on outer join + ambiguous inlined relation + attribute selection
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7238
diff changeset
   245
    cardinality = '?*'