mixins.py
branchstable
changeset 5309 e8567135a927
parent 4719 aaed3f813ef8
child 5421 8167de96c523
equal deleted inserted replaced
5308:c691a424d9e0 5309:e8567135a927
     1 """mixins of entity/views organized somewhat in a graph or tree structure
     1 # organization: Logilab
     2 
     2 # copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     3 
     3 # contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
     4 :organization: Logilab
     4 # license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
     5 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
     5 """mixins of entity/views organized somewhat in a graph or tree structure"""
     6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     7 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
       
     8 """
       
     9 __docformat__ = "restructuredtext en"
     6 __docformat__ = "restructuredtext en"
    10 
     7 
    11 from itertools import chain
     8 from itertools import chain
    12 
     9 
    13 from logilab.common.decorators import cached
    10 from logilab.common.decorators import cached
    15 from cubicweb.selectors import implements
    12 from cubicweb.selectors import implements
    16 from cubicweb.interfaces import IEmailable, ITree
    13 from cubicweb.interfaces import IEmailable, ITree
    17 
    14 
    18 
    15 
    19 class TreeMixIn(object):
    16 class TreeMixIn(object):
    20     """base tree-mixin providing the tree interface
    17     """base tree-mixin implementing the tree interface
    21 
    18 
    22     This mixin has to be inherited explicitly and configured using the
    19     This mixin has to be inherited explicitly and configured using the
    23     tree_attribute, parent_target and children_target class attribute to
    20     tree_attribute, parent_target and children_target class attribute to
    24     benefit from this default implementation
    21     benefit from this default implementation
    25     """
    22     """
   273             self.w(self.separator)
   270             self.w(self.separator)
   274         entity.view(vid or self.item_vid, w=self.w)
   271         entity.view(vid or self.item_vid, w=self.w)
   275 
   272 
   276 
   273 
   277 class ProgressMixIn(object):
   274 class ProgressMixIn(object):
   278     """provide default implementations for IProgress interface methods"""
   275     """provide a default implementations for IProgress interface methods"""
   279     # This is an adapter isn't it ?
       
   280 
   276 
   281     @property
   277     @property
   282     def cost(self):
   278     def cost(self):
   283         return self.progress_info()['estimated']
   279         return self.progress_info()['estimated']
   284 
   280