web/component.py
branchtls-sprint
changeset 661 4f61eb8a96b7
parent 659 5d754a1933cb
child 670 6c332f5c969c
equal deleted inserted replaced
660:5233a9457f6b 661:4f61eb8a96b7
     4 :copyright: 2001-2009 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.deprecation import class_moved
       
    10 
     9 from cubicweb.selectors import (
    11 from cubicweb.selectors import (
    10     paginated_rset, one_line_rset, primary_view, match_context_prop,
    12     paginated_rset, one_line_rset, primary_view, match_context_prop,
    11     condition_compat, accepts_compat, has_relation_compat)
    13     condition_compat, accepts_compat, has_relation_compat)
    12 from cubicweb.common.appobject import Component, SingletonComponent, ComponentMixIn
    14 from cubicweb.common.appobject import Component
    13 from cubicweb.common.utils import merge_dicts
    15 from cubicweb.common.utils import merge_dicts
    14 from cubicweb.common.view import View
    16 from cubicweb.common.view import View
    15 from cubicweb.common.registerers import action_registerer
    17 from cubicweb.common.registerers import action_registerer
    16 from cubicweb.common.uilib import html_escape
    18 from cubicweb.common.uilib import html_escape
    17 
    19 
    18 _ = unicode
    20 _ = unicode
    19 
    21 
    20 class VComponent(ComponentMixIn, View):
    22 class EntityVComponent(Component):
    21     property_defs = {
       
    22         _('visible'):  dict(type='Boolean', default=True,
       
    23                             help=_('display the box or not')),
       
    24         }    
       
    25 
       
    26 class EntityVComponent(VComponent):
       
    27     """abstract base class for additinal components displayed in content
    23     """abstract base class for additinal components displayed in content
    28     headers and footer according to:
    24     headers and footer according to:
    29     
    25     
    30     * the displayed entity's type
    26     * the displayed entity's type
    31     * a context (currently 'header' or 'footer')
    27     * a context (currently 'header' or 'footer')
    60 
    56 
    61     def cell_call(self, row, col, view):
    57     def cell_call(self, row, col, view):
    62         raise NotImplementedError()
    58         raise NotImplementedError()
    63 
    59 
    64     
    60     
    65 class NavigationComponent(ComponentMixIn, View):
    61 class NavigationComponent(Component):
    66     """abstract base class for navigation components"""
    62     """abstract base class for navigation components"""
    67     id = 'navigation'
    63     id = 'navigation'
    68     __selectors__ = (paginated_rset,)
    64     __selectors__ = (paginated_rset,)
    69     
    65     
    70     page_size_property = 'navigation.page-size'
    66     page_size_property = 'navigation.page-size'
   173         if not rset.rowcount:
   169         if not rset.rowcount:
   174             return
   170             return
   175         self.w(u'<div class="%s">' % self.div_class())
   171         self.w(u'<div class="%s">' % self.div_class())
   176         self.wview(self.vid, rset, title=self.req._(self.title).capitalize())
   172         self.wview(self.vid, rset, title=self.req._(self.title).capitalize())
   177         self.w(u'</div>')
   173         self.w(u'</div>')
       
   174 
       
   175 
       
   176 VComponent = class_moved('VComponent', VComponent,
       
   177                          'VComponent is deprecated, use Component')
       
   178 SingletonVComponent = class_moved('SingletonVComponent', VComponent,
       
   179                                   'SingletonVComponent is deprecated, use Component and explicit registration control')