hooks/test/data/schema.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 03 Feb 2016 14:23:17 +0100
changeset 11091 29aebc1edd29
parent 10666 7f6b5f023884
permissions -rw-r--r--
[repository] drop usage of no more necessary eschema_eid function since the previous cset, we are guaranteed that repository's entity schema will have their eid attribute properly set, so we don't have anymore to check everytime if some entity schema's .eid attributes is set or not (and retrieve it if not). Related to #10450092
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9548
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
     1
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
9361
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     3
#
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     4
# This file is part of CubicWeb.
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     5
#
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
     9
# any later version.
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    10
#
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    14
# details.
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    15
#
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    18
10387
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    19
from yams.buildobjs import (RelationDefinition, RelationType, EntityType,
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    20
                            String, Datetime, Int)
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    21
from yams.reader import context
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    22
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    23
from cubicweb.schema import ERQLExpression
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    24
10666
7f6b5f023884 [py3k] replace '_ = unicode' in global scope (closes #7589459)
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10387
diff changeset
    25
from cubicweb import _
9361
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    26
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    27
class friend(RelationDefinition):
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    28
    subject = ('CWUser', 'CWGroup')
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    29
    object = ('CWUser', 'CWGroup')
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    30
    symmetric = True
0542a85fe667 symmetric relations: replace bogus rql2sql translation by a hook
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff changeset
    31
9548
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    32
class Folder(EntityType):
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    33
    name = String()
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    34
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    35
class parent(RelationDefinition):
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    36
    subject = 'Folder'
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    37
    object = 'Folder'
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    38
    composite = 'object'
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    39
    cardinality = '?*'
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    40
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    41
class children(RelationDefinition):
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    42
    subject = 'Folder'
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    43
    object = 'Folder'
be001628edad [schema] fix composite deletion handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9361
diff changeset
    44
    composite = 'subject'
10387
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    45
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    46
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    47
class Email(EntityType):
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    48
    """electronic mail"""
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    49
    subject   = String(fulltextindexed=True)
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    50
    date      = Datetime(description=_('UTC time on which the mail was sent'))
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    51
    messageid = String(required=True, indexed=True)
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    52
    headers   = String(description=_('raw headers'))
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    53
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    54
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    55
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    56
class EmailPart(EntityType):
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    57
    """an email attachment"""
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    58
    __permissions__ = {
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    59
        'read':   ('managers', 'users', 'guests',), # XXX if E parts X, U has_read_permission E
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    60
        'add':    ('managers', ERQLExpression('E parts X, U has_update_permission E'),),
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    61
        'delete': ('managers', ERQLExpression('E parts X, U has_update_permission E')),
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    62
        'update': ('managers', 'owners',),
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    63
        }
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    64
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    65
    content  = String(fulltextindexed=True)
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    66
    content_format = String(required=True, maxsize=50)
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    67
    ordernum = Int(required=True)
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    68
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    69
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    70
class parts(RelationType):
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    71
    subject = 'Email'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    72
    object = 'EmailPart'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    73
    cardinality = '*1'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    74
    composite = 'subject'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    75
    fulltext_container = 'subject'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    76
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    77
class sender(RelationDefinition):
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    78
    subject = 'Email'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    79
    object = 'EmailAddress'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    80
    cardinality = '?*'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    81
    inlined = True
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    82
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    83
class recipients(RelationDefinition):
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    84
    subject = 'Email'
67890235cb78 [test] stop depending on the email cube for hooks test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 9548
diff changeset
    85
    object = 'EmailAddress'