schemas/bootstrap.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 23 Apr 2010 09:17:08 +0200
changeset 5380 a4e7e87d315f
parent 5179 f08943f22334
child 5421 8167de96c523
permissions -rw-r--r--
[c-c status] return status code 1 when some instances isn't running. Closes #510817
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
     1
"""core CubicWeb schema necessary for bootstrapping the actual instance's schema
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     2
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
:organization: Logilab
4212
ab6573088b4a update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
     4
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1451
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
"""
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
     8
__docformat__ = "restructuredtext en"
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
     9
_ = unicode
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
    11
from yams.buildobjs import (EntityType, RelationType, RelationDefinition,
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
    12
                            SubjectRelation, RichString, String, Boolean, Int)
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    13
from cubicweb.schema import (
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    14
    RQLConstraint,
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    15
    PUB_SYSTEM_ENTITY_PERMS, PUB_SYSTEM_REL_PERMS, PUB_SYSTEM_ATTR_PERMS
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    16
    )
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    17
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
# not restricted since as "is" is handled as other relations, guests need
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
# access to this
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
    20
class CWEType(EntityType):
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
    21
    """define an entity type, used to build the instance schema"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    22
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
    name = String(required=True, indexed=True, internationalizable=True,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
                  unique=True, maxsize=64)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    25
    description = RichString(internationalizable=True,
627
36ade1128af7 use RichString wherever possible in the stdlib
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 0
diff changeset
    26
                             description=_('semantic description of this entity type'))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
    # necessary to filter using RQL
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
    final = Boolean(description=_('automatic'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
    31
class CWRType(EntityType):
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
    32
    """define a relation type, used to build the instance schema"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    33
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
    name = String(required=True, indexed=True, internationalizable=True,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
                  unique=True, maxsize=64)
2129
fbfab570a276 use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2127
diff changeset
    36
    description = RichString(internationalizable=True,
fbfab570a276 use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2127
diff changeset
    37
                             description=_('semantic description of this relation type'))
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: 4319
diff changeset
    38
    symmetric = Boolean(description=_('is this relation equivalent in both direction ?'))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
    inlined = Boolean(description=_('is this relation physically inlined? you should know what you\'re doing if you are changing this!'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
    fulltext_container = String(description=_('if full text content of subject/object entity '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
                                              'should be added to other side entity (the container).'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
                                vocabulary=('', _('subject'), _('object')),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
                                maxsize=8, default=None)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
    final = Boolean(description=_('automatic'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
    47
class CWAttribute(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    48
    """define a final relation: link a final relation type from a non final
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    49
    entity to a final entity type.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
    51
    used to build the instance schema
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
    """
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    53
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
    54
    relation_type = SubjectRelation('CWRType', cardinality='1*',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    55
                                    constraints=[RQLConstraint('O final TRUE')],
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
                                    composite='object')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
    57
    from_entity = SubjectRelation('CWEType', cardinality='1*',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
                                  constraints=[RQLConstraint('O final FALSE')],
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    59
                                  composite='object')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
    60
    to_entity = SubjectRelation('CWEType', cardinality='1*',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    61
                                constraints=[RQLConstraint('O final TRUE')],
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    62
                                composite='object')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
    63
    constrained_by = SubjectRelation('CWConstraint', cardinality='*1', composite='subject')
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    64
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
    cardinality = String(maxsize=2, internationalizable=True,
1979
daf297034197 remove meaningless cards for attributes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    66
                         vocabulary=[_('?1'), _('11')],
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
                         description=_('subject/object cardinality'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
    ordernum = Int(description=('control subject entity\'s relations order'), default=0)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    69
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
    indexed = Boolean(description=_('create an index for quick search on this attribute'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
    fulltextindexed = Boolean(description=_('index this attribute\'s value in the plain text index'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
    internationalizable = Boolean(description=_('is this attribute\'s value translatable'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
    defaultval = String(maxsize=256)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    74
2129
fbfab570a276 use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2127
diff changeset
    75
    description = RichString(internationalizable=True,
fbfab570a276 use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2127
diff changeset
    76
                             description=_('semantic description of this attribute'))
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    77
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    79
CARDINALITY_VOCAB = [_('?*'), _('1*'), _('+*'), _('**'),
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    80
                     _('?+'), _('1+'), _('++'), _('*+'),
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    81
                     _('?1'), _('11'), _('+1'), _('*1'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    82
                     _('??'), _('1?'), _('+?'), _('*?')]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    83
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
    84
class CWRelation(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    85
    """define a non final relation: link a non final relation type from a non
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    86
    final entity to a non final entity type.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    87
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2459
diff changeset
    88
    used to build the instance schema
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    89
    """
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
    90
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
    91
    relation_type = SubjectRelation('CWRType', cardinality='1*',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    92
                                    constraints=[RQLConstraint('O final FALSE')],
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    93
                                    composite='object')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
    94
    from_entity = SubjectRelation('CWEType', cardinality='1*',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    95
                                  constraints=[RQLConstraint('O final FALSE')],
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
                                  composite='object')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
    97
    to_entity = SubjectRelation('CWEType', cardinality='1*',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    98
                                constraints=[RQLConstraint('O final FALSE')],
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    99
                                composite='object')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
   100
    constrained_by = SubjectRelation('CWConstraint', cardinality='*1', composite='subject')
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   101
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
    cardinality = String(maxsize=2, internationalizable=True,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
                         vocabulary=CARDINALITY_VOCAB,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
                         description=_('subject/object cardinality'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
    ordernum = Int(description=_('control subject entity\'s relations order'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
                   default=0)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   107
    composite = String(description=_('is the subject/object entity of the relation '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   108
                                     'composed of the other ? This implies that when '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   109
                                     'the composite is deleted, composants are also '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   110
                                     'deleted.'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   111
                       vocabulary=('', _('subject'), _('object')),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
                       maxsize=8, default=None)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   113
2129
fbfab570a276 use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2127
diff changeset
   114
    description = RichString(internationalizable=True,
fbfab570a276 use RichString
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2127
diff changeset
   115
                             description=_('semantic description of this relation'))
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   116
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   117
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   118
# not restricted since it has to be read when checking allowed transitions
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   119
class RQLExpression(EntityType):
4535
71c86a315a9a update translatable docstring
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   120
    """define a rql expression used to define permissions"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   121
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   122
    exprtype = String(required=True, vocabulary=['ERQLExpression', 'RRQLExpression'])
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   123
    mainvars = String(maxsize=8,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   124
                      description=_('name of the main variables which should be '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   125
                                    'used in the selection if necessary (comma '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
                                    'separated)'))
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   127
    expression = String(required=True,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   128
                        description=_('restriction part of a rql query. '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
                                      'For entity rql expression, X and U are '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   130
                                      'predefined respectivly to the current object and to '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   131
                                      'the request user. For relation rql expression, '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   132
                                      'S, O and U are predefined respectivly to the current '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   133
                                      'relation\'subject, object and to '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   134
                                      'the request user. '))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   135
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   136
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   137
class CWConstraint(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   138
    """define a schema constraint"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   139
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
   140
    cstrtype = SubjectRelation('CWConstraintType', cardinality='1*')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   141
    value = String(description=_('depends on the constraint type'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   142
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   143
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   144
class CWConstraintType(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   145
    """define a schema constraint type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   146
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   147
    name = String(required=True, indexed=True, internationalizable=True,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   148
                  unique=True, maxsize=64)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   150
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   151
# not restricted since it has to be read when checking allowed transitions
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   152
class CWGroup(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
    """define a CubicWeb users group"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   154
    __permissions__ = PUB_SYSTEM_ENTITY_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   155
    name = String(required=True, indexed=True, internationalizable=True,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   156
                  unique=True, maxsize=64)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   157
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   158
3392
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   159
class CWProperty(EntityType):
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   160
    """used for cubicweb configuration. Once a property has been created you
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   161
    can't change the key.
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   162
    """
4003
b9436fe77c9e fix bad merge
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 3890
diff changeset
   163
    __permissions__ = {
3392
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   164
        'read':   ('managers', 'users', 'guests'),
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   165
        'add':    ('managers', 'users',),
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   166
        'update': ('managers', 'owners',),
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   167
        'delete': ('managers', 'owners',),
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   168
        }
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   169
    # key is a reserved word for mysql
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   170
    pkey = String(required=True, internationalizable=True, maxsize=256,
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   171
                  description=_('defines what\'s the property is applied for. '
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   172
                                'You must select this first to be able to set '
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   173
                                'value'))
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   174
    value = String(internationalizable=True, maxsize=256)
36bcf206e157 [schema] CWProperty is required at bootstrap time
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2476
diff changeset
   175
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   176
class relation_type(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   177
    """link a relation definition to its relation type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   178
    __permissions__ = PUB_SYSTEM_REL_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   179
    inlined = True
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   180
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   181
class from_entity(RelationType):
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   182
    """link a relation definition to its subject entity type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   183
    __permissions__ = PUB_SYSTEM_REL_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   184
    inlined = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   185
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   186
class to_entity(RelationType):
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   187
    """link a relation definition to its object entity type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   188
    __permissions__ = PUB_SYSTEM_REL_PERMS
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   189
    inlined = True
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   190
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   191
class constrained_by(RelationType):
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   192
    """constraints applying on this relation"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   193
    __permissions__ = PUB_SYSTEM_REL_PERMS
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   194
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   195
class cstrtype(RelationType):
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   196
    """constraint factory"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   197
    __permissions__ = PUB_SYSTEM_REL_PERMS
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   198
    inlined = True
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   199
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   200
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   201
class read_permission_cwgroup(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   202
    """groups allowed to read entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   203
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   204
    name = 'read_permission'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   205
    subject = ('CWEType', 'CWAttribute', 'CWRelation')
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   206
    object = 'CWGroup'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   207
    cardinality = '**'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   208
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   209
class add_permission_cwgroup(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   210
    """groups allowed to add entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   211
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   212
    name = 'add_permission'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   213
    subject = ('CWEType', 'CWRelation')
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   214
    object = 'CWGroup'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   215
    cardinality = '**'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   216
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   217
class delete_permission_cwgroup(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   218
    """groups allowed to delete entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   219
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   220
    name = 'delete_permission'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   221
    subject = ('CWEType', 'CWRelation')
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   222
    object = 'CWGroup'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   223
    cardinality = '**'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   224
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   225
class update_permission_cwgroup(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   226
    """groups allowed to update entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   227
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   228
    name = 'update_permission'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   229
    subject = ('CWEType', 'CWAttribute')
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   230
    object = 'CWGroup'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   231
    cardinality = '**'
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   232
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   233
class read_permission_rqlexpr(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   234
    """rql expression allowing to read entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   235
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   236
    name = 'read_permission'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   237
    subject = ('CWEType', 'CWAttribute', 'CWRelation')
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   238
    object = 'RQLExpression'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   239
    cardinality = '*?'
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   240
    composite = 'subject'
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   241
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   242
class add_permission_rqlexpr(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   243
    """rql expression allowing to add entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   244
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   245
    name = 'add_permission'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   246
    subject = ('CWEType', 'CWRelation')
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   247
    object = 'RQLExpression'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   248
    cardinality = '*?'
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   249
    composite = 'subject'
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   250
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   251
class delete_permission_rqlexpr(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   252
    """rql expression allowing to delete entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   253
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   254
    name = 'delete_permission'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   255
    subject = ('CWEType', 'CWRelation')
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   256
    object = 'RQLExpression'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   257
    cardinality = '*?'
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   258
    composite = 'subject'
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   259
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   260
class update_permission_rqlexpr(RelationDefinition):
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   261
    """rql expression allowing to update entities/relations of this type"""
4754
6bf17f810975 [schema] new constants for permissions definitions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4588
diff changeset
   262
    __permissions__ = PUB_SYSTEM_REL_PERMS
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   263
    name = 'update_permission'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   264
    subject = ('CWEType', 'CWAttribute')
4588
36b700c00d38 fix *_permissions schema: using the same cardinality/composite properties for cwgroup/rqlexpr leads to important pbs...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4570
diff changeset
   265
    object = 'RQLExpression'
4570
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   266
    cardinality = '*?'
ede247bbbf62 follow yams api change: attributes permissions are now defined for
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4535
diff changeset
   267
    composite = 'subject'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   268
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   269
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   270
class is_(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   271
    """core relation indicating the type of an entity
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   272
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   273
    name = 'is'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   274
    # don't explicitly set composite here, this is handled anyway
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   275
    #composite = 'object'
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2476
diff changeset
   276
    __permissions__ = {
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   277
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   278
        'add':    (),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   279
        'delete': (),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   280
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   281
    cardinality = '1*'
2438
576f4d51f826 [cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2140
diff changeset
   282
    subject = '*'
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
   283
    object = 'CWEType'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   284
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   285
class is_instance_of(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   286
    """core relation indicating the types (including specialized types)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   287
    of an entity
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   288
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   289
    # don't explicitly set composite here, this is handled anyway
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   290
    #composite = 'object'
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2476
diff changeset
   291
    __permissions__ = {
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   292
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   293
        'add':    (),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   294
        'delete': (),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   295
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   296
    cardinality = '+*'
2438
576f4d51f826 [cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2140
diff changeset
   297
    subject = '*'
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
   298
    object = 'CWEType'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   299
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2129
diff changeset
   300
class specializes(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   301
    name = 'specializes'
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2476
diff changeset
   302
    __permissions__ = {
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   303
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   304
        'add':    ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   305
        'delete': ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   306
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   307
    cardinality = '?*'
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
   308
    subject = 'CWEType'
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 628
diff changeset
   309
    object = 'CWEType'
4755
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   310
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   311
def post_build_callback(schema):
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   312
    """set attributes permissions for schema/workflow entities"""
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   313
    from cubicweb.schema import SCHEMA_TYPES, WORKFLOW_TYPES, META_RTYPES
5179
f08943f22334 [schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4755
diff changeset
   314
    wftypes = WORKFLOW_TYPES - set(('TrInfo',))
4755
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   315
    for eschema in schema.entities():
5179
f08943f22334 [schema] #847739: test and fix bad permission on TrInfo.comment
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4755
diff changeset
   316
        if eschema in SCHEMA_TYPES or eschema in wftypes:
4755
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   317
            for rschema in eschema.subject_relations():
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   318
                if rschema.final and not rschema in META_RTYPES:
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   319
                    rdef = eschema.rdef(rschema)
13a5d3a7410e [schema] tweaks meta-relations and schema/workflow entities attributes permissions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4754
diff changeset
   320
                    rdef.permissions = PUB_SYSTEM_ATTR_PERMS