entity.py
changeset 8793 3305b4a9df49
parent 8791 892fc9e0c8df
child 8892 80783605d270
child 8900 010a59e12d89
equal deleted inserted replaced
8792:4b6d3d0a853e 8793:3305b4a9df49
  1393     def __iter__(self):
  1393     def __iter__(self):
  1394         return iter(self.cw_attr_cache)
  1394         return iter(self.cw_attr_cache)
  1395 
  1395 
  1396     @deprecated('[3.10] use entity.cw_attr_cache[attr]')
  1396     @deprecated('[3.10] use entity.cw_attr_cache[attr]')
  1397     def __getitem__(self, key):
  1397     def __getitem__(self, key):
  1398         if key == 'eid':
       
  1399             warn('[3.7] entity["eid"] is deprecated, use entity.eid instead',
       
  1400                  DeprecationWarning, stacklevel=2)
       
  1401             return self.eid
       
  1402         return self.cw_attr_cache[key]
  1398         return self.cw_attr_cache[key]
  1403 
  1399 
  1404     @deprecated('[3.10] use entity.cw_attr_cache.get(attr[, default])')
  1400     @deprecated('[3.10] use entity.cw_attr_cache.get(attr[, default])')
  1405     def get(self, key, default=None):
  1401     def get(self, key, default=None):
  1406         return self.cw_attr_cache.get(key, default)
  1402         return self.cw_attr_cache.get(key, default)
  1420 
  1416 
  1421         and this way, cw_edited will be updated accordingly. Also, add
  1417         and this way, cw_edited will be updated accordingly. Also, add
  1422         the attribute to skip_security since we don't want to check security
  1418         the attribute to skip_security since we don't want to check security
  1423         for such attributes set by hooks.
  1419         for such attributes set by hooks.
  1424         """
  1420         """
  1425         if attr == 'eid':
  1421         try:
  1426             warn('[3.7] entity["eid"] = value is deprecated, use entity.eid = value instead',
  1422             self.cw_edited[attr] = value
  1427                  DeprecationWarning, stacklevel=2)
  1423         except AttributeError:
  1428             self.eid = value
  1424             self.cw_attr_cache[attr] = value
  1429         else:
       
  1430             try:
       
  1431                 self.cw_edited[attr] = value
       
  1432             except AttributeError:
       
  1433                 self.cw_attr_cache[attr] = value
       
  1434 
  1425 
  1435     @deprecated('[3.10] use del entity.cw_edited[attr]')
  1426     @deprecated('[3.10] use del entity.cw_edited[attr]')
  1436     def __delitem__(self, attr):
  1427     def __delitem__(self, attr):
  1437         """override __delitem__ to update self.cw_edited on cleanup of
  1428         """override __delitem__ to update self.cw_edited on cleanup of
  1438         undesired changes introduced in the entity's dict. For example, see the
  1429         undesired changes introduced in the entity's dict. For example, see the