web/box.py
branchtls-sprint
changeset 640 8e64f12be69c
parent 526 498ff2e16fae
child 652 603c782dc092
equal deleted inserted replaced
635:305da8d6aa2d 640:8e64f12be69c
     1 """abstract box classes for CubicWeb web client
     1 """abstract box classes for CubicWeb web client
     2 
     2 
     3 :organization: Logilab
     3 :organization: Logilab
     4 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     6 """
     6 """
     7 __docformat__ = "restructuredtext en"
     7 __docformat__ = "restructuredtext en"
     8 
     8 
     9 from logilab.common.decorators import cached
     9 from logilab.common.decorators import cached
    12 from cubicweb import Unauthorized, role as get_role
    12 from cubicweb import Unauthorized, role as get_role
    13 from cubicweb.common.registerers import (
    13 from cubicweb.common.registerers import (
    14     accepts_registerer, extresources_registerer,
    14     accepts_registerer, extresources_registerer,
    15     etype_rtype_priority_registerer)
    15     etype_rtype_priority_registerer)
    16 from cubicweb.common.selectors import (
    16 from cubicweb.common.selectors import (
    17     etype_rtype_selector, one_line_rset, accept, has_relation,
    17     one_line_rset,  primary_view, match_context_prop, has_related_entities,
    18     primary_view, match_context_prop, has_related_entities,
    18     accept_compat)
    19     _rql_condition)
    19 #etype_rtype_selector, has_relation,
    20 from cubicweb.common.view import Template
    20 from cubicweb.common.view import Template
    21 from cubicweb.common.appobject import ReloadableMixIn
    21 from cubicweb.common.appobject import ReloadableMixIn
    22 
    22 
    23 from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget,
    23 from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget,
    24                                       RawBoxItem, BoxSeparator)
    24                                       RawBoxItem, BoxSeparator)
   104     It rely on etype, rtype (both optional, usable to control registration
   104     It rely on etype, rtype (both optional, usable to control registration
   105     according to application schema and display according to connected
   105     according to application schema and display according to connected
   106     user's rights) and rql attributes
   106     user's rights) and rql attributes
   107     """
   107     """
   108     __registerer__ = etype_rtype_priority_registerer
   108     __registerer__ = etype_rtype_priority_registerer
   109     __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,)
   109 #XXX    __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,)
   110 
   110 
   111     rql  = None
   111     rql  = None
   112     
   112     
   113     def to_display_rql(self):
   113     def to_display_rql(self):
   114         assert self.rql is not None, self.id
   114         assert self.rql is not None, self.id
   149 
   149 
   150 class EntityBoxTemplate(BoxTemplate):
   150 class EntityBoxTemplate(BoxTemplate):
   151     """base class for boxes related to a single entity"""
   151     """base class for boxes related to a single entity"""
   152     __registerer__ = accepts_registerer
   152     __registerer__ = accepts_registerer
   153     __selectors__ = (one_line_rset, primary_view,
   153     __selectors__ = (one_line_rset, primary_view,
   154                      match_context_prop, etype_rtype_selector,
   154                      match_context_prop,)
   155                      has_relation, accept, _rql_condition)
   155                      #etype_rtype_selector, has_relation)
   156     accepts = ('Any',)
   156     registered = accepts_compat(condition_compat(BoxTemplate.registered.im_func))
   157     context = 'incontext'
   157     context = 'incontext'
   158     condition = None
       
   159     
   158     
   160     def call(self, row=0, col=0, **kwargs):
   159     def call(self, row=0, col=0, **kwargs):
   161         """classes inheriting from EntityBoxTemplate should define cell_call"""
   160         """classes inheriting from EntityBoxTemplate should define cell_call"""
   162         self.cell_call(row, col, **kwargs)
   161         self.cell_call(row, col, **kwargs)
   163 
   162