# HG changeset patch # User Sverre Rabbelier # Date 1235667095 0 # Node ID 8df06dc877aa5cff05df3bb6a8dec5c47c48fa36 # Parent 75de65fcb017ebb494fb4f28b0f6c92e509e306a Do not update newly created model properties There is no real reason to favor old behavior over the current, plus the new behavior saves an extra disk write (which are expensive). Patch by: Sverre Rabbelier diff -r 75de65fcb017 -r 8df06dc877aa app/soc/logic/models/base.py --- a/app/soc/logic/models/base.py Thu Feb 26 16:50:59 2009 +0000 +++ b/app/soc/logic/models/base.py Thu Feb 26 16:51:35 2009 +0000 @@ -384,12 +384,10 @@ if create_entity: # entity did not exist, so create one in a transaction entity = self._model.get_or_insert(key_name, **properties) - - - # there is no way to be sure if get_or_insert() returned a new entity or - # got an existing one due to a race, so update with properties anyway, - # in a transaction - entity = self.updateEntityProperties(entity, properties, silent=True) + else: + # If someone else already created the entity (due to a race), we + # should not update the propties (as they 'won' the race). + entity = self.updateEntityProperties(entity, properties, silent=True) if create_entity: # a new entity has been created call _onCreate