common/mixins.py
changeset 3451 6b46d73823f5
parent 3426 6ea4a2ff01c9
child 3457 0924d0d08d60
equal deleted inserted replaced
3448:495862266785 3451:6b46d73823f5
    36         """
    36         """
    37         res = self.related(self.tree_attribute, self.children_target,
    37         res = self.related(self.tree_attribute, self.children_target,
    38                            entities=entities)
    38                            entities=entities)
    39         if entities:
    39         if entities:
    40             return [e for e in res if e.e_schema != self.e_schema]
    40             return [e for e in res if e.e_schema != self.e_schema]
    41         return res.filtered_rset(lambda x: x.e_schema != self.e_schema, self.col)
    41         return res.filtered_rset(lambda x: x.e_schema != self.e_schema, self.cw_col)
    42 
    42 
    43     def same_type_children(self, entities=True):
    43     def same_type_children(self, entities=True):
    44         """return children entities of the same type as this entity.
    44         """return children entities of the same type as this entity.
    45 
    45 
    46         according to the `entities` parameter, return entity objects or the
    46         according to the `entities` parameter, return entity objects or the
    48         """
    48         """
    49         res = self.related(self.tree_attribute, self.children_target,
    49         res = self.related(self.tree_attribute, self.children_target,
    50                            entities=entities)
    50                            entities=entities)
    51         if entities:
    51         if entities:
    52             return [e for e in res if e.e_schema == self.e_schema]
    52             return [e for e in res if e.e_schema == self.e_schema]
    53         return res.filtered_rset(lambda x: x.e_schema == self.e_schema, self.col)
    53         return res.filtered_rset(lambda x: x.e_schema == self.e_schema, self.cw_col)
    54 
    54 
    55     def iterchildren(self, _done=None):
    55     def iterchildren(self, _done=None):
    56         if _done is None:
    56         if _done is None:
    57             _done = set()
    57             _done = set()
    58         for child in self.children():
    58         for child in self.children():
   247         self.w(u'</li>\n')
   247         self.w(u'</li>\n')
   248 
   248 
   249 
   249 
   250 class TreePathMixIn(object):
   250 class TreePathMixIn(object):
   251     """a recursive path view"""
   251     """a recursive path view"""
   252     id = 'path'
   252     __regid__ = 'path'
   253     item_vid = 'oneline'
   253     item_vid = 'oneline'
   254     separator = u'&#160;&gt;&#160;'
   254     separator = u'&#160;&gt;&#160;'
   255 
   255 
   256     def call(self, **kwargs):
   256     def call(self, **kwargs):
   257         self.w(u'<div class="pathbar">')
   257         self.w(u'<div class="pathbar">')