entity.py
changeset 10609 e2d8e81bfe68
parent 10467 73ea636a5562
child 10612 84468b90e9c1
equal deleted inserted replaced
10608:7fc548d9dd8e 10609:e2d8e81bfe68
    19 
    19 
    20 __docformat__ = "restructuredtext en"
    20 __docformat__ = "restructuredtext en"
    21 
    21 
    22 from warnings import warn
    22 from warnings import warn
    23 from functools import partial
    23 from functools import partial
       
    24 
       
    25 from six.moves import range
    24 
    26 
    25 from logilab.common.decorators import cached
    27 from logilab.common.decorators import cached
    26 from logilab.common.deprecation import deprecated
    28 from logilab.common.deprecation import deprecated
    27 from logilab.common.registry import yes
    29 from logilab.common.registry import yes
    28 from logilab.mtconverter import TransformData, xml_escape
    30 from logilab.mtconverter import TransformData, xml_escape
   890                 rset = self._cw.execute(rql, {'x': self.eid}, build_descr=False)[0]
   892                 rset = self._cw.execute(rql, {'x': self.eid}, build_descr=False)[0]
   891             except IndexError:
   893             except IndexError:
   892                 raise Exception('unable to fetch attributes for entity with eid %s'
   894                 raise Exception('unable to fetch attributes for entity with eid %s'
   893                                 % self.eid)
   895                                 % self.eid)
   894             # handle attributes
   896             # handle attributes
   895             for i in xrange(1, lastattr):
   897             for i in range(1, lastattr):
   896                 self.cw_attr_cache[str(selected[i-1][0])] = rset[i]
   898                 self.cw_attr_cache[str(selected[i-1][0])] = rset[i]
   897             # handle relations
   899             # handle relations
   898             for i in xrange(lastattr, len(rset)):
   900             for i in range(lastattr, len(rset)):
   899                 rtype, role = selected[i-1][0]
   901                 rtype, role = selected[i-1][0]
   900                 value = rset[i]
   902                 value = rset[i]
   901                 if value is None:
   903                 if value is None:
   902                     rrset = ResultSet([], rql, {'x': self.eid})
   904                     rrset = ResultSet([], rql, {'x': self.eid})
   903                     rrset.req = self._cw
   905                     rrset.req = self._cw