web/views/schema.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 03 Jul 2009 17:57:33 +0200
branchstable
changeset 2256 0b915d6f4264
parent 2231 d2052c3ccac7
child 2234 1fbcf202882d
child 2276 33e7488a407c
permissions -rw-r--r--
no more true since a while
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
"""Specific views for schema related entities
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: 1739
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: 1739
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"
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     9
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    10
from itertools import cycle
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    11
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    12
from logilab.mtconverter import html_escape
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    13
from yams import schema2dot as s2d
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    14
1132
96752791c2b6 pylint cleanup
sylvain.thenault@logilab.fr
parents: 1091
diff changeset
    15
from cubicweb.selectors import implements, yes
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
from cubicweb.schemaviewer import SchemaViewer
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    17
from cubicweb.view import EntityView, StartupView
1556
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
    18
from cubicweb.common import tags, uilib
1739
78b0819162a8 final rtag api
sylvain.thenault@logilab.fr
parents: 1725
diff changeset
    19
from cubicweb.web import action
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    20
from cubicweb.web.views import TmpFileViewMixin, primary, baseviews, tabs
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    21
from cubicweb.web.facet import AttributeFacet
1151
b20677336ee6 turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    22
b20677336ee6 turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    23
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    24
class ViewSchemaAction(action.Action):
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    25
    id = 'schema'
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    26
    __select__ = yes()
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    27
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    28
    title = _("site schema")
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    29
    category = 'siteactions'
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    30
    order = 30
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    31
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    32
    def url(self):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    33
        return self.build_url(self.id)
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    34
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    35
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    36
class CWRDEFPrimaryView(primary.PrimaryView):
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    37
    __select__ = implements('CWAttribute', 'CWRelation')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    38
    cache_max_age = 60*60*2 # stay in http cache for 2 hours by default
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    39
1720
14c9a0a1aca1 drop content_title
sylvain.thenault@logilab.fr
parents: 1580
diff changeset
    40
    def render_entity_title(self, entity):
14c9a0a1aca1 drop content_title
sylvain.thenault@logilab.fr
parents: 1580
diff changeset
    41
        self.w(u'<h1><span class="etype">%s</span> %s</h1>'
14c9a0a1aca1 drop content_title
sylvain.thenault@logilab.fr
parents: 1580
diff changeset
    42
               % (entity.dc_type().capitalize(),
1723
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1721
diff changeset
    43
                  html_escape(entity.dc_long_title())))
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    44
2228
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    45
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    46
# CWEType ######################################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
    48
class CWETypeOneLineView(baseviews.OneLineView):
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
    49
    __select__ = implements('CWEType')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    50
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    51
    def cell_call(self, row, col, **kwargs):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    52
        entity = self.entity(row, col)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    53
        final = entity.final
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    54
        if final:
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    55
            self.w(u'<em class="finalentity">')
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
    56
        super(CWETypeOneLineView, self).cell_call(row, col, **kwargs)
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    57
        if final:
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    58
            self.w(u'</em>')
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    59
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    60
SKIPPED_RELS = ('is', 'is_instance_of', 'identity', 'created_by', 'owned_by',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    61
                'has_text',)
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    62
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    63
class CWETypePrimaryView(tabs.TabsMixin, primary.PrimaryView):
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    64
    __select__ = implements('CWEType')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
    title = _('in memory entity schema')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
    main_related_section = False
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    67
    skip_rels = SKIPPED_RELS
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1998
diff changeset
    68
    tabs = [_('cwetype-schema-text'), _('cwetype-schema-image'),
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    69
            _('cwetype-schema-permissions'), _('cwetype-workflow')]
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    70
    default_tab = 'cwetype-schema-text'
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    71
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    72
    def render_entity(self, entity):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    73
        self.render_entity_title(entity)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    74
        self.w(u'<div>%s</div>' % entity.description)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    75
        self.render_tabs(self.tabs, self.default_tab, entity)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    76
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    77
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    78
class CWETypeSTextView(EntityView):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    79
    id = 'cwetype-schema-text'
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    80
    __select__ = EntityView.__select__ & implements('CWEType')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    81
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    82
    def cell_call(self, row, col):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    83
        entity = self.entity(row, col)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    84
        self.w(u'<h2>%s</h2>' % _('Attributes'))
2231
d2052c3ccac7 won't get anything useful like this (currently, list of constraint's eids), should use a custom table view (later...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2228
diff changeset
    85
        rset = self.req.execute('Any N,F,D,I,J,DE,A '
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    86
                                'ORDERBY AA WHERE A is CWAttribute, '
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    87
                                'A ordernum AA, A defaultval D, '
2231
d2052c3ccac7 won't get anything useful like this (currently, list of constraint's eids), should use a custom table view (later...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2228
diff changeset
    88
                                'A description DE, '
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    89
                                'A fulltextindexed I, A internationalizable J, '
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    90
                                'A relation_type R, R name N, '
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    91
                                'A to_entity O, O name F, '
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    92
                                'A from_entity S, S eid %(x)s',
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    93
                                {'x': entity.eid})
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    94
        self.wview('editable-table', rset, 'null', displayfilter=True)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
    95
        self.w(u'<h2>%s</h2>' % _('Relations'))
2228
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    96
        rset = self.req.execute(
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    97
            'Any R,C,TT,K,D,A,RN,TTN ORDERBY RN '
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    98
            'WHERE A is CWRelation, A description D, A composite K?, '
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
    99
            'A relation_type R, R name RN, A to_entity TT, TT name TTN, '
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   100
            'A cardinality C, A from_entity S, S eid %(x)s',
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   101
            {'x': entity.eid})
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   102
        self.wview('editable-table', rset, 'null', displayfilter=True,
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   103
                   displaycols=range(6), mainindex=5)
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   104
        rset = self.req.execute(
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   105
            'Any R,C,TT,K,D,A,RN,TTN ORDERBY RN '
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   106
            'WHERE A is CWRelation, A description D, A composite K?, '
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   107
            'A relation_type R, R name RN, A from_entity TT, TT name TTN, '
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   108
            'A cardinality C, A to_entity O, O eid %(x)s',
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   109
            {'x': entity.eid})
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   110
        self.wview('editable-table', rset, 'null', displayfilter=True,
7e85d0169911 some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2172
diff changeset
   111
                   displaycols=range(6), mainindex=5)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   112
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   113
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   114
class CWETypeSImageView(EntityView):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   115
    id = 'cwetype-schema-image'
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   116
    __select__ = EntityView.__select__ & implements('CWEType')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   117
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   118
    def cell_call(self, row, col):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   119
        entity = self.entity(row, col)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   120
        url = entity.absolute_url(vid='schemagraph')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   121
        self.w(u'<img src="%s" alt="%s"/>' % (
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   122
            html_escape(url),
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   123
            html_escape(self.req._('graphical schema for %s') % entity.name)))
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   124
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   125
class CWETypeSPermView(EntityView):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   126
    id = 'cwetype-schema-permissions'
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   127
    __select__ = EntityView.__select__ & implements('CWEType')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   128
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   129
    def cell_call(self, row, col):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   130
        entity = self.entity(row, col)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   131
        self.w(u'<h2>%s</h2>' % _('Add permissions'))
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   132
        rset = self.req.execute('Any P WHERE X add_permission P, '
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1998
diff changeset
   133
                                'X eid %(x)s',
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   134
                                {'x': entity.eid})
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   135
        self.wview('outofcontext', rset, 'null')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   136
        self.w(u'<h2>%s</h2>' % _('Read permissions'))
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   137
        rset = self.req.execute('Any P WHERE X read_permission P, '
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1998
diff changeset
   138
                                'X eid %(x)s',
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   139
                                {'x': entity.eid})
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   140
        self.wview('outofcontext', rset, 'null')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   141
        self.w(u'<h2>%s</h2>' % _('Update permissions'))
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   142
        rset = self.req.execute('Any P WHERE X update_permission P, '
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1998
diff changeset
   143
                                'X eid %(x)s',
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   144
                                {'x': entity.eid})
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   145
        self.wview('outofcontext', rset, 'null')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   146
        self.w(u'<h2>%s</h2>' % _('Delete permissions'))
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   147
        rset = self.req.execute('Any P WHERE X delete_permission P, '
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1998
diff changeset
   148
                                'X eid %(x)s',
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   149
                                {'x': entity.eid})
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   150
        self.wview('outofcontext', rset, 'null')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   151
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   152
class CWETypeSWorkflowView(EntityView):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   153
    id = 'cwetype-workflow'
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   154
    __select__ = EntityView.__select__ & implements('CWEType')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   155
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   156
    def cell_call(self, row, col):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   157
        entity = self.entity(row, col)
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   158
        if entity.reverse_state_of:
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   159
            self.w(u'<img src="%s" alt="%s"/>' % (
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   160
                    html_escape(entity.absolute_url(vid='ewfgraph')),
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   161
                    html_escape(self.req._('graphical workflow for %s') % entity.name)))
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   162
        else:
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   163
            self.w(u'<p>%s</p>' % _('There is no workflow defined for this entity.'))
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   164
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   165
# CWRType ######################################################################
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   166
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   167
class CWRTypeSchemaView(primary.PrimaryView):
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   168
    __select__ = implements('CWRType')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   169
    title = _('in memory relation schema')
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   170
    main_related_section = False
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   171
1556
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   172
    def render_entity_attributes(self, entity):
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   173
        super(CWRTypeSchemaView, self).render_entity_attributes(entity)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   174
        rschema = self.vreg.schema.rschema(entity.name)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   175
        viewer = SchemaViewer(self.req)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   176
        layout = viewer.visit_relationschema(rschema)
1556
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   177
        self.w(uilib.ureport_as_html(layout))
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   178
        if not rschema.is_final():
1556
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   179
            msg = self.req._('graphical schema for %s') % entity.name
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   180
            self.w(tags.img(src=entity.absolute_url(vid='schemagraph'),
1556
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   181
                            alt=msg))
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   182
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   183
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   184
# schema images ###############################################################
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   185
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   186
class RestrictedSchemaDotPropsHandler(s2d.SchemaDotPropsHandler):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   187
    def __init__(self, req):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   188
        # FIXME: colors are arbitrary
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   189
        self.nextcolor = cycle( ('#aa0000', '#00aa00', '#0000aa',
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   190
                                 '#000000', '#888888') ).next
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   191
        self.req = req
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   192
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   193
    def display_attr(self, rschema):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   194
        return not rschema.meta and (rschema.has_local_role('read')
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   195
                                     or rschema.has_perm(self.req, 'read'))
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   196
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   197
    # XXX remove this method once yams > 0.20 is out
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   198
    def node_properties(self, eschema):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   199
        """return default DOT drawing options for an entity schema"""
1132
96752791c2b6 pylint cleanup
sylvain.thenault@logilab.fr
parents: 1091
diff changeset
   200
        label = ['{', eschema.type, '|']
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   201
        label.append(r'\l'.join(rel.type for rel in eschema.subject_relations()
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   202
                                if rel.final and self.display_attr(rel)))
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   203
        label.append(r'\l}') # trailing \l ensure alignement of the last one
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   204
        return {'label' : ''.join(label), 'shape' : "record",
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   205
                'fontname' : "Courier", 'style' : "filled"}
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   206
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   207
    def edge_properties(self, rschema, subjnode, objnode):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   208
        kwargs = super(RestrictedSchemaDotPropsHandler, self).edge_properties(rschema, subjnode, objnode)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   209
        # symetric rels are handled differently, let yams decide what's best
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   210
        if not rschema.symetric:
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   211
            kwargs['color'] = self.nextcolor()
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   212
        kwargs['fontcolor'] = kwargs['color']
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   213
        # dot label decoration is just awful (1 line underlining the label
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   214
        # + 1 line going to the closest edge spline point)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   215
        kwargs['decorate'] = 'false'
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   216
        return kwargs
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   217
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   218
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   219
class RestrictedSchemaVisitorMiIn:
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   220
    def __init__(self, req, *args, **kwargs):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   221
        # hack hack hack
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   222
        assert len(self.__class__.__bases__) == 2
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   223
        self.__parent = self.__class__.__bases__[1]
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   224
        self.__parent.__init__(self, *args, **kwargs)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   225
        self.req = req
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   226
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   227
    def nodes(self):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   228
        for etype, eschema in self.__parent.nodes(self):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   229
            if eschema.has_local_role('read') or eschema.has_perm(self.req, 'read'):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   230
                yield eschema.type, eschema
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   231
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   232
    def edges(self):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   233
        for setype, oetype, rschema in self.__parent.edges(self):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   234
            if rschema.has_local_role('read') or rschema.has_perm(self.req, 'read'):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   235
                yield setype, oetype, rschema
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   236
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   237
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   238
class FullSchemaVisitor(RestrictedSchemaVisitorMiIn, s2d.FullSchemaVisitor):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   239
    pass
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   240
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   241
class OneHopESchemaVisitor(RestrictedSchemaVisitorMiIn, s2d.OneHopESchemaVisitor):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   242
    pass
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   243
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   244
class OneHopRSchemaVisitor(RestrictedSchemaVisitorMiIn, s2d.OneHopRSchemaVisitor):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   245
    pass
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   246
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   247
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   248
class SchemaImageView(TmpFileViewMixin, StartupView):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   249
    id = 'schemagraph'
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   250
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   251
    content_type = 'image/png'
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   252
    skip_rels = SKIPPED_RELS
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   253
    def _generate(self, tmpfile):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   254
        """display global schema information"""
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   255
        skipmeta = not int(self.req.form.get('withmeta', 0))
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   256
        visitor = FullSchemaVisitor(self.req, self.schema, skiprels=self.skip_rels, skipmeta=skipmeta)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   257
        s2d.schema2dot(outputfile=tmpfile, visitor=visitor,
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   258
                       prophdlr=RestrictedSchemaDotPropsHandler(self.req))
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   259
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   260
class CWETypeSchemaImageView(TmpFileViewMixin, EntityView):
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   261
    id = 'schemagraph'
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   262
    __select__ = implements('CWEType')
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   263
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   264
    content_type = 'image/png'
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   265
    skip_rels = SKIPPED_RELS
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   266
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   267
    def _generate(self, tmpfile):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   268
        """display schema information for an entity"""
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   269
        entity = self.entity(self.row, self.col)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   270
        eschema = self.vreg.schema.eschema(entity.name)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   271
        visitor = OneHopESchemaVisitor(self.req, eschema, skiprels=self.skip_rels)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   272
        s2d.schema2dot(outputfile=tmpfile, visitor=visitor,
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   273
                       prophdlr=RestrictedSchemaDotPropsHandler(self.req))
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   274
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   275
class CWRTypeSchemaImageView(CWETypeSchemaImageView):
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   276
    __select__ = implements('CWRType')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   277
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   278
    def _generate(self, tmpfile):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   279
        """display schema information for an entity"""
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   280
        entity = self.entity(self.row, self.col)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   281
        rschema = self.vreg.schema.rschema(entity.name)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   282
        visitor = OneHopRSchemaVisitor(self.req, rschema)
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   283
        s2d.schema2dot(outputfile=tmpfile, visitor=visitor,
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   284
                       prophdlr=RestrictedSchemaDotPropsHandler(self.req))
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   285
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   286
### facets
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   287
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   288
class CWMetaFacet(AttributeFacet):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   289
    id = 'cwmeta-facet'
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   290
    __select__ = AttributeFacet.__select__ & implements('CWEType')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   291
    rtype = 'meta'
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   292
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   293
class CWFinalFacet(AttributeFacet):
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   294
    id = 'cwfinal-facet'
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   295
    __select__ = AttributeFacet.__select__ & implements('CWEType')
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   296
    rtype = 'final'