Prevent modification of key fields
Only non-id-based entities are affected as id-based entities do not
have any un-modificable fields.
--- 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):