# HG changeset patch # User Sverre Rabbelier # Date 1253617647 -7200 # Node ID 7ba28890eb7528170f2cc68f6c09aec1ee025576 # Parent 676c0ca67e21ab7f28b37b8ecfe6f3b3e34752f4 Prevent modification of key fields Only non-id-based entities are affected as id-based entities do not have any un-modificable fields. diff -r 676c0ca67e21 -r 7ba28890eb75 app/soc/logic/models/base.py --- a/app/soc/logic/models/base.py Tue Sep 22 13:15:33 2009 +0200 +++ b/app/soc/logic/models/base.py Tue Sep 22 13:07:27 2009 +0200 @@ -87,6 +87,21 @@ else: self._skip_properties = [] + def skipField(self, name): + """Returns whether a field with the specified name should be saved. + """ + + if name in self._skip_properties: + return True + + if self._id_based: + return False + + if name in self.getKeyFieldNames(): + return True + + return False + def getModel(self): """Returns the model this logic class uses. """ @@ -453,7 +468,7 @@ for name, prop in properties.iteritems(): # if the property is not updateable or is not updated, skip it - if name in self._skip_properties or (name not in entity_properties): + if self.skipField(name) or (name not in entity_properties): continue if self._updateField(entity, entity_properties, name):