# HG changeset patch # User Sverre Rabbelier # Date 1235667185 0 # Node ID f6f43a1675eb5c76e09fb52c8356488f034da84b # Parent a467d13e34ea16712fb08750dd876f0d7d13e726 Add a _createField hook Patch by: Sverre Rabbelier diff -r a467d13e34ea -r f6f43a1675eb app/soc/logic/models/base.py --- a/app/soc/logic/models/base.py Thu Feb 26 16:52:29 2009 +0000 +++ b/app/soc/logic/models/base.py Thu Feb 26 16:53:05 2009 +0000 @@ -383,6 +383,9 @@ create_entity = not entity if create_entity: + for property_name in properties: + self._createField(properties, property_name) + # entity did not exist, so create one in a transaction entity = self._model.get_or_insert(key_name, **properties) else: @@ -419,6 +422,23 @@ # entity has been deleted call _onDelete self._onDelete(entity) + def _createField(self, entity_properties, name): + """Hook called when a field is created. + + To be exact, this method is called for each field (that has a value + specified) on an entity that is being created. + + Base classes should override if any special actions need to be + taken when a field is updated. + + Args: + name: the name of the field to be created + value: the value + """ + + if not entity_properties or (name not in entity_properties): + raise InvalidArgumentError + def _updateField(self, entity, entity_properties, name): """Hook called when a field is updated.