entities/schemaobjs.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 17 Feb 2011 18:43:45 +0100
branchstable
changeset 7012 5ff6cb8bd2b3
parent 6912 b61b844f2dad
child 6944 0cf10429ad39
permissions -rw-r--r--
[schema serialization] for relation type, ertidx contains the relation type as string, for relation def, the RelationDefinitionSchema instance
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
6427
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    18
"""schema definition related entities"""
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
__docformat__ = "restructuredtext en"
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
6427
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    22
import re
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    23
from socket import gethostname
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    24
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
from logilab.common.decorators import cached
6427
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    26
from logilab.common.textutils import text_to_dict
6627
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    27
from logilab.common.configuration import OptionError
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
5030
5238d9a8dfee [form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4839
diff changeset
    29
from yams.schema import role_name
5238d9a8dfee [form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4839
diff changeset
    30
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
from cubicweb import ValidationError
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
from cubicweb.schema import ERQLExpression, RRQLExpression
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
from cubicweb.entities import AnyEntity, fetch_config
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
6627
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    37
class _CWSourceCfgMixIn(object):
6427
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    38
    @property
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    39
    def dictconfig(self):
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    40
        return self.config and text_to_dict(self.config) or {}
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    41
6627
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    42
    def update_config(self, skip_unknown=False, **config):
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    43
        from cubicweb.server import SOURCE_TYPES
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    44
        from cubicweb.server.serverconfig import (SourceConfiguration,
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    45
                                                  generate_source_config)
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    46
        cfg = self.dictconfig
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    47
        cfg.update(config)
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    48
        options = SOURCE_TYPES[self.type].options
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    49
        sconfig = SourceConfiguration(self._cw.vreg.config, options=options)
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    50
        for opt, val in cfg.iteritems():
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    51
            try:
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    52
                sconfig.set_option(opt, val)
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    53
            except OptionError:
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    54
                if skip_unknown:
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    55
                    continue
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    56
                raise
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    57
        cfgstr = unicode(generate_source_config(sconfig), self._cw.encoding)
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    58
        self.set_attributes(config=cfgstr)
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    59
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    60
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    61
class CWSource(_CWSourceCfgMixIn, AnyEntity):
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    62
    __regid__ = 'CWSource'
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    63
    fetch_attrs, fetch_order = fetch_config(['name', 'type'])
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    64
6427
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    65
    @property
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    66
    def host_config(self):
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    67
        dictconfig = self.dictconfig
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    68
        host = gethostname()
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    69
        for hostcfg in self.host_configs:
6578
7abd07ff0471 [cwsource] fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6427
diff changeset
    70
            if hostcfg.match(host):
6632
78878f5a8166 cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6627
diff changeset
    71
                self.info('matching host config %s for source %s',
78878f5a8166 cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6627
diff changeset
    72
                          hostcfg.match_host, self.name)
6427
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    73
                dictconfig.update(hostcfg.dictconfig)
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    74
        return dictconfig
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    75
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    76
    @property
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    77
    def host_configs(self):
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    78
        return self.reverse_cw_host_config_of
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    79
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    80
6627
430b7703b3fd [sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6578
diff changeset
    81
class CWSourceHostConfig(_CWSourceCfgMixIn, AnyEntity):
6427
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    82
    __regid__ = 'CWSourceHostConfig'
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    83
    fetch_attrs, fetch_order = fetch_config(['match_host', 'config'])
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    84
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    85
    def match(self, hostname):
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    86
        return re.match(self.match_host, hostname)
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    87
c8a5ac2d1eaa [schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5556
diff changeset
    88
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1154
diff changeset
    89
class CWEType(AnyEntity):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3353
diff changeset
    90
    __regid__ = 'CWEType'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    91
    fetch_attrs, fetch_order = fetch_config(['name'])
1154
9b23a6836c32 support for old __rtags__
sylvain.thenault@logilab.fr
parents: 0
diff changeset
    92
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    93
    def dc_title(self):
3432
12fe502e5044 use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3377
diff changeset
    94
        return u'%s (%s)' % (self.name, self._cw._(self.name))
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
    95
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    96
    def dc_long_title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    97
        stereotypes = []
3432
12fe502e5044 use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3377
diff changeset
    98
        _ = self._cw._
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    99
        if self.final:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   100
            stereotypes.append(_('final'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   101
        if stereotypes:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   102
            return u'%s <<%s>>' % (self.dc_title(), ', '.join(stereotypes))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   103
        return self.dc_title()
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   104
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   105
    def db_key_name(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   106
        """XXX goa specific"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   107
        return self.get('name')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   108
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   109
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1154
diff changeset
   110
class CWRType(AnyEntity):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3353
diff changeset
   111
    __regid__ = 'CWRType'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
    fetch_attrs, fetch_order = fetch_config(['name'])
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   113
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   114
    def dc_title(self):
3432
12fe502e5044 use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3377
diff changeset
   115
        return u'%s (%s)' % (self.name, self._cw._(self.name))
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   116
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   117
    def dc_long_title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   118
        stereotypes = []
3432
12fe502e5044 use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3377
diff changeset
   119
        _ = self._cw._
4467
0e73d299730a fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
   120
        if self.symmetric:
0e73d299730a fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4252
diff changeset
   121
            stereotypes.append(_('symmetric'))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   122
        if self.inlined:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   123
            stereotypes.append(_('inlined'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   124
        if self.final:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   125
            stereotypes.append(_('final'))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   126
        if stereotypes:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   127
            return u'%s <<%s>>' % (self.dc_title(), ', '.join(stereotypes))
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   128
        return self.dc_title()
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   129
4839
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   130
    def check_inlined_allowed(self):
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   131
        """check inlining is possible, raise ValidationError if not possible
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   132
        """
4839
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   133
        # don't use the persistent schema, we may miss cardinality changes
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   134
        # in the same transaction
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   135
        for rdef in self.reverse_relation_type:
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   136
            card = rdef.cardinality[0]
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   137
            if not card in '?1':
5030
5238d9a8dfee [form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4839
diff changeset
   138
                qname = role_name('inlined', 'subject')
4839
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   139
                rtype = self.name
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   140
                stype = rdef.stype
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   141
                otype = rdef.otype
6912
b61b844f2dad [schema sync] fix crash when bad inlinment detected, inlined is not in the locals
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6632
diff changeset
   142
                msg = self._cw._("can't set inlined=True, "
4839
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   143
                                 "%(stype)s %(rtype)s %(otype)s "
f482dbdf2f8c [schema hooks] properly check for changes of schema properties avoid useless costly operation (such as full-text reindexing all entities of a type). Refactor inlined handling and fix a bug trying to reindex a final entity type on the way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4467
diff changeset
   144
                                 "has cardinality=%(card)s")
5030
5238d9a8dfee [form] put qualified name on validation error, should fix #784299
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4839
diff changeset
   145
                raise ValidationError(self.eid, {qname: msg % locals()})
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   146
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   147
    def db_key_name(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   148
        """XXX goa specific"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   149
        return self.get('name')
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
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1154
diff changeset
   152
class CWRelation(AnyEntity):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3353
diff changeset
   153
    __regid__ = 'CWRelation'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   154
    fetch_attrs = fetch_config(['cardinality'])[0]
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   155
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   156
    def dc_title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   157
        return u'%s %s %s' % (
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   158
            self.from_entity[0].name,
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   159
            self.relation_type[0].name,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   160
            self.to_entity[0].name)
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   161
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   162
    def dc_long_title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   163
        card = self.cardinality
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   164
        scard, ocard = u'', u''
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   165
        if card[0] != '1':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   166
            scard = '[%s]' % card[0]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   167
        if card[1] != '1':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   168
            ocard = '[%s]' % card[1]
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   169
        return u'%s %s%s%s %s' % (
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   170
            self.from_entity[0].name,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   171
            scard, self.relation_type[0].name, ocard,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   172
            self.to_entity[0].name)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   173
2594
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   174
    @property
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   175
    def rtype(self):
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   176
        return self.relation_type[0]
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   177
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   178
    @property
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   179
    def stype(self):
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   180
        return self.from_entity[0]
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   181
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   182
    @property
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   183
    def otype(self):
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   184
        return self.to_entity[0]
92aad5e18405 [R schemaobjs] property accessors for CWRelation/CWAttribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2299
diff changeset
   185
5239
471554b842d2 [schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5224
diff changeset
   186
    def yams_schema(self):
471554b842d2 [schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5224
diff changeset
   187
        rschema = self._cw.vreg.schema.rschema(self.rtype.name)
471554b842d2 [schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5224
diff changeset
   188
        return rschema.rdefs[(self.stype.name, self.otype.name)]
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   189
5556
9ab2b4c74baf [entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
   190
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1154
diff changeset
   191
class CWAttribute(CWRelation):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3353
diff changeset
   192
    __regid__ = 'CWAttribute'
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   193
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   194
    def dc_long_title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   195
        card = self.cardinality
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   196
        scard = u''
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   197
        if card[0] == '1':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   198
            scard = '+'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   199
        return u'%s %s%s %s' % (
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   200
            self.from_entity[0].name,
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   201
            scard, self.relation_type[0].name,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   202
            self.to_entity[0].name)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   203
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   204
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1154
diff changeset
   205
class CWConstraint(AnyEntity):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3353
diff changeset
   206
    __regid__ = 'CWConstraint'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   207
    fetch_attrs, fetch_order = fetch_config(['value'])
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   208
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   209
    def dc_title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   210
        return '%s(%s)' % (self.cstrtype[0].name, self.value or u'')
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   211
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   212
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   213
    def type(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   214
        return self.cstrtype[0].name
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   215
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   216
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   217
class RQLExpression(AnyEntity):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3353
diff changeset
   218
    __regid__ = 'RQLExpression'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   219
    fetch_attrs, fetch_order = fetch_config(['exprtype', 'mainvars', 'expression'])
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   220
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   221
    def dc_title(self):
5224
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
   222
        return self.expression or u''
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
   223
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5030
diff changeset
   224
    def dc_long_title(self):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   225
        return '%s(%s)' % (self.exprtype, self.expression or u'')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   226
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   227
    @property
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   228
    def expression_of(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   229
        for rel in ('read_permission', 'add_permission', 'delete_permission',
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   230
                    'update_permission', 'condition'):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   231
            values = getattr(self, 'reverse_%s' % rel)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   232
            if values:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   233
                return values[0]
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   234
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   235
    @cached
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   236
    def _rqlexpr(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   237
        if self.exprtype == 'ERQLExpression':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   238
            return ERQLExpression(self.expression, self.mainvars, self.eid)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   239
        #if self.exprtype == 'RRQLExpression':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   240
        return RRQLExpression(self.expression, self.mainvars, self.eid)
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   241
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   242
    def check_expression(self, *args, **kwargs):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   243
        return self._rqlexpr().check(*args, **kwargs)
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1398
diff changeset
   244
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   245
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1154
diff changeset
   246
class CWPermission(AnyEntity):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3353
diff changeset
   247
    __regid__ = 'CWPermission'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   248
    fetch_attrs, fetch_order = fetch_config(['name', 'label'])
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   249
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   250
    def dc_title(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   251
        if self.label:
3432
12fe502e5044 use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3377
diff changeset
   252
            return '%s (%s)' % (self._cw._(self.name), self.label)
12fe502e5044 use ._cw instead of req on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3377
diff changeset
   253
        return self._cw._(self.name)