entity.py
branchstable
changeset 4990 3bf481cf51cb
parent 4989 0e6dca27422c
child 4991 16f0cec3d008
equal deleted inserted replaced
4989:0e6dca27422c 4990:3bf481cf51cb
   247             warn('[3.7] entity["eid"] = value is deprecated, use entity.eid = value instead',
   247             warn('[3.7] entity["eid"] = value is deprecated, use entity.eid = value instead',
   248                  DeprecationWarning, stacklevel=2)
   248                  DeprecationWarning, stacklevel=2)
   249             self.eid = value
   249             self.eid = value
   250         else:
   250         else:
   251             super(Entity, self).__setitem__(attr, value)
   251             super(Entity, self).__setitem__(attr, value)
   252             if hasattr(self, 'edited_attributes'):
   252             # don't add attribute into skip_security if already in edited
       
   253             # attributes, else we may accidentaly skip a desired security check
       
   254             if hasattr(self, 'edited_attributes') and \
       
   255                    attr not in self.edited_attributes:
   253                 self.edited_attributes.add(attr)
   256                 self.edited_attributes.add(attr)
   254                 self.skip_security_attributes.add(attr)
   257                 self.skip_security_attributes.add(attr)
   255 
   258 
   256     def __delitem__(self, attr):
   259     def __delitem__(self, attr):
   257         """override __delitem__ to update self.edited_attributes on cleanup of
   260         """override __delitem__ to update self.edited_attributes on cleanup of
   274             self.edited_attributes.remove(attr)
   277             self.edited_attributes.remove(attr)
   275 
   278 
   276     def setdefault(self, attr, default):
   279     def setdefault(self, attr, default):
   277         """override setdefault to update self.edited_attributes"""
   280         """override setdefault to update self.edited_attributes"""
   278         super(Entity, self).setdefault(attr, default)
   281         super(Entity, self).setdefault(attr, default)
   279         if hasattr(self, 'edited_attributes'):
   282         # don't add attribute into skip_security if already in edited
       
   283         # attributes, else we may accidentaly skip a desired security check
       
   284         if hasattr(self, 'edited_attributes') and \
       
   285                attr not in self.edited_attributes:
   280             self.edited_attributes.add(attr)
   286             self.edited_attributes.add(attr)
   281             self.skip_security_attributes.add(attr)
   287             self.skip_security_attributes.add(attr)
   282 
   288 
   283     def rql_set_value(self, attr, value):
   289     def rql_set_value(self, attr, value):
   284         """call by rql execution plan when some attribute is modified
   290         """call by rql execution plan when some attribute is modified