schemas/base.py
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Wed, 26 Aug 2009 20:23:27 +0200
branchstable
changeset 3030 e086df78e267
parent 2656 a93ae0f6c0ad
child 3204 0b766b8a13e1
permissions -rw-r--r--
B [views] fixing breadcrumbs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
"""core CubicWeb schema, but not necessary at bootstrap time
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
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1742
diff changeset
     4
:copyright: 2001-2009 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: 1742
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
"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     8
__docformat__ = "restructuredtext en"
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
     9
_ = unicode
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    11
from yams.buildobjs import (EntityType, RelationType, SubjectRelation,
2297
4cf57dd80650 missing imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2140
diff changeset
    12
                            String, Boolean, Datetime, Password)
4cf57dd80650 missing imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2140
diff changeset
    13
from cubicweb.schema import (RQLConstraint, WorkflowableEntityType,
4cf57dd80650 missing imports
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2140
diff changeset
    14
                             ERQLExpression, RRQLExpression)
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    15
from cubicweb.schemas import META_ETYPE_PERMS, META_RTYPE_PERMS
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1303
diff changeset
    17
class CWUser(WorkflowableEntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
    """define a CubicWeb user"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
        'read':   ('managers', 'users', ERQLExpression('X identity U')),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
        'add':    ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
        'delete': ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
        'update': ('managers', ERQLExpression('X identity U, NOT U in_group G, G name "guests"'),),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
    login     = String(required=True, unique=True, maxsize=64,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
                       description=_('unique identifier used to connect to the application'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
    upassword = Password(required=True) # password is a reserved word for mysql
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
    firstname = String(maxsize=64)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
    surname   = String(maxsize=64)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
    last_login_time  = Datetime(description=_('last connection date'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
    # allowing an email to be the primary email of multiple entities is necessary for
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    33
    # test at least :-/
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
    primary_email = SubjectRelation('EmailAddress', cardinality='??',
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
                                    description=_('email address to use for notification'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
    use_email     = SubjectRelation('EmailAddress', cardinality='*?', composite='subject')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1303
diff changeset
    38
    in_group = SubjectRelation('CWGroup', cardinality='+*',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
                               constraints=[RQLConstraint('NOT O name "owners"')],
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
                               description=_('groups grant permissions to the user'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    43
class EmailAddress(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
    """an electronic mail address associated to a short alias"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
        'read':   ('managers', 'users', 'guests',), # XXX if P use_email X, U has_read_permission P
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
        'add':    ('managers', 'users',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    48
        'delete': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    49
        'update': ('managers', 'owners', ERQLExpression('P use_email X, U has_update_permission P')),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
        }
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    51
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
    alias   = String(fulltextindexed=True, maxsize=56)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    53
    address = String(required=True, fulltextindexed=True,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    54
                     indexed=True, unique=True, maxsize=128)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    55
    canonical = Boolean(default=False,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
                        description=_('when multiple addresses are equivalent \
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
(such as python-projects@logilab.org and python-projects@lists.logilab.org), set this \
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
to true on one of them which is the preferred form.'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    59
    identical_to = SubjectRelation('EmailAddress')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    60
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    61
class use_email(RelationType):
1742
25a765e756c4 fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 1477
diff changeset
    62
    """ """
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
        'read':   ('managers', 'users', 'guests',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
        'add':    ('managers', RRQLExpression('U has_update_permission S'),),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
        'delete': ('managers', RRQLExpression('U has_update_permission S'),),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
    fulltext_container = 'subject'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
class primary_email(RelationType):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
    """the prefered email"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
    permissions = use_email.permissions
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    73
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    74
class identical_to(RelationType):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
    """identical_to"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
    symetric = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
        'read':   ('managers', 'users', 'guests',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    79
        # XXX should have update permissions on both subject and object,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    80
        #     though by doing this we will probably have no way to add
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    81
        #     this relation in the web ui. The easiest way to acheive this
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    82
        #     is probably to be able to have "U has_update_permission O" as
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    83
        #     RQLConstraint of the relation definition, though this is not yet
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    84
        #     possible
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    85
        'add':    ('managers', RRQLExpression('U has_update_permission S'),),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    86
        'delete': ('managers', RRQLExpression('U has_update_permission S'),),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    87
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    88
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    89
class in_group(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    90
    """core relation indicating a user's groups"""
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    91
    permissions = META_RTYPE_PERMS
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    92
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    93
class owned_by(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    94
    """core relation indicating owners of an entity. This relation
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    95
    implicitly put the owner into the owners group for the entity
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    97
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    98
        'read':   ('managers', 'users', 'guests'),
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    99
        'add':    ('managers', RRQLExpression('S owned_by U'),),
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   100
        'delete': ('managers', RRQLExpression('S owned_by U'),),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   101
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
    # 0..n cardinality for entities created by internal session (no attached user)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
    # and to support later deletion of a user which has created some entities
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
    cardinality = '**'
2438
576f4d51f826 [cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2297
diff changeset
   105
    subject = '*'
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1303
diff changeset
   106
    object = 'CWUser'
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   107
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   108
class created_by(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   109
    """core relation indicating the original creator of an entity"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   110
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   111
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
        'add':    ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   113
        'delete': ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   114
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   115
    # 0..1 cardinality for entities created by internal session (no attached user)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   116
    # and to support later deletion of a user which has created some entities
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   117
    cardinality = '?*'
2438
576f4d51f826 [cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2297
diff changeset
   118
    subject = '*'
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1303
diff changeset
   119
    object = 'CWUser'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   120
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   121
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   122
class creation_date(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   123
    """creation time of an entity"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   124
    cardinality = '11'
2438
576f4d51f826 [cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2297
diff changeset
   125
    subject = '*'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
    object = 'Datetime'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   127
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   128
class modification_date(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
    """latest modification time of an entity"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   130
    cardinality = '11'
2438
576f4d51f826 [cleanup] fix deprecation warnings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2297
diff changeset
   131
    subject = '*'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   132
    object = 'Datetime'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   133
2456
aa25d6b244c8 new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2441
diff changeset
   134
class cwuri(RelationType):
aa25d6b244c8 new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2441
diff changeset
   135
    """internal entity uri"""
aa25d6b244c8 new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2441
diff changeset
   136
    cardinality = '11'
2464
926696e38502 usage of '**' is deprecated in RelationType declaration, use '*' instead
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2456
diff changeset
   137
    subject = '*'
2456
aa25d6b244c8 new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2441
diff changeset
   138
    object = 'String'
aa25d6b244c8 new cwuri metadata + a few tests fixes on the way
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2441
diff changeset
   139
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   140
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1303
diff changeset
   141
class CWProperty(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   142
    """used for cubicweb configuration. Once a property has been created you
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   143
    can't change the key.
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   144
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   145
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   147
        'add':    ('managers', 'users',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   148
        'update': ('managers', 'owners',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
        'delete': ('managers', 'owners',),
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
    # key is a reserved word for mysql
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   152
    pkey = String(required=True, internationalizable=True, maxsize=256,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   153
                  description=_('defines what\'s the property is applied for. '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   154
                                'You must select this first to be able to set '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   155
                                'value'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   156
    value = String(internationalizable=True, maxsize=256)
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   157
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1303
diff changeset
   158
    for_user = SubjectRelation('CWUser', cardinality='?*', composite='object',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   159
                               description=_('user for which this property is '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   160
                                             'applying. If this relation is not '
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   161
                                             'set, the property is considered as'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   162
                                             ' a global property'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   163
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   164
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   165
class for_user(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   166
    """link a property to the user which want this property customization. Unless
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   167
    you're a site manager, this relation will be handled automatically.
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   168
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   169
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   170
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   171
        'add':    ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   172
        'delete': ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   173
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   174
    inlined = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   175
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   176
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   177
class CWPermission(EntityType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   178
    """entity type that may be used to construct some advanced security configuration
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   179
    """
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   180
    permissions = META_ETYPE_PERMS
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   181
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   182
    name = String(required=True, indexed=True, internationalizable=True, maxsize=100,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   183
                  description=_('name or identifier of the permission'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   184
    label = String(required=True, internationalizable=True, maxsize=100,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   185
                   description=_('distinct label to distinguate between other permission entity of the same name'))
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   186
    require_group = SubjectRelation('CWGroup',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   187
                                    description=_('groups to which the permission is granted'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   188
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1303
diff changeset
   189
# explicitly add X require_permission CWPermission for each entity that should have
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   190
# configurable security
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   191
class require_permission(RelationType):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   192
    """link a permission to the entity. This permission should be used in the
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   193
    security definition of the entity's type to be useful.
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   194
    """
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   195
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   196
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   197
        'add':    ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   198
        'delete': ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   199
        }
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   200
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   201
class require_group(RelationType):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   202
    """used to grant a permission to a group"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   203
    permissions = {
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   204
        'read':   ('managers', 'users', 'guests'),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   205
        'add':    ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   206
        'delete': ('managers',),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   207
        }
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   208
1451
982e8616d9a2 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   209
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   210
class see_also(RelationType):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   211
    """generic relation to link one entity to another"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   212
    symetric = True
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   213
2434
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   214
class ExternalUri(EntityType):
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   215
    """a URI representing an object in external data store"""
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   216
    uri = String(required=True, unique=True, maxsize=256,
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   217
                 description=_('the URI of the object'))
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   218
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   219
class same_as(RelationType):
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   220
    """generic relation to specify that an external entity represent the same
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   221
    object as a local one:
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   222
       http://www.w3.org/TR/owl-ref/#sameAs-def
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   223
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   224
    NOTE: You'll have to explicitly declare which entity types can have a
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   225
    same_as relation
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   226
    """
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   227
    permissions = {
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   228
        'read':   ('managers', 'users', 'guests',),
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   229
        'add':    ('managers', 'users'),
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   230
        'delete': ('managers', 'owners'),
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   231
        }
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   232
    cardinality = '*1'
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   233
    symetric = True
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   234
    # NOTE: the 'object = ExternalUri' declaration will still be mandatory
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   235
    #       in the cube's schema.
ed85d69576b4 add sameAs support in cubicweb standard schema
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 2297
diff changeset
   236
    object = 'ExternalUri'
1477
b056a49c16dc backport default branch
sylvain.thenault@logilab.fr
parents: 1451 1445
diff changeset
   237
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   238
class CWCache(EntityType):
59
9660bd221553 ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6
diff changeset
   239
    """a simple cache entity characterized by a name and
9660bd221553 ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6
diff changeset
   240
    a validity date.
9660bd221553 ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6
diff changeset
   241
9660bd221553 ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6
diff changeset
   242
    The target application is responsible for updating timestamp
9660bd221553 ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6
diff changeset
   243
    when necessary to invalidate the cache (typically in hooks).
9660bd221553 ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6
diff changeset
   244
2656
a93ae0f6c0ad R [base classes] only AppObject remaning, no more AppRsetObject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2464
diff changeset
   245
    Also, checkout the AppObject.get_cache() method.
59
9660bd221553 ECache should be a meta entity
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6
diff changeset
   246
    """
6
29ab115b9fcb change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 0
diff changeset
   247
    permissions = {
29ab115b9fcb change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 0
diff changeset
   248
        'read':   ('managers', 'users', 'guests'),
29ab115b9fcb change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 0
diff changeset
   249
        'add':    ('managers',),
2140
1cba3393ba01 update schema definition to avoid deprecation warning with new yams api
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   250
        'update': ('managers', 'users',), # XXX
6
29ab115b9fcb change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 0
diff changeset
   251
        'delete': ('managers',),
29ab115b9fcb change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 0
diff changeset
   252
        }
29ab115b9fcb change permissions for Ecache
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents: 0
diff changeset
   253
1445
d3c9b075ceb7 set a size constraint on ECache's title
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1281
diff changeset
   254
    name = String(required=True, unique=True, indexed=True,  maxsize=128,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   255
                  description=_('name of the cache'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   256
    timestamp = Datetime(default='NOW')