app/soc/logic/models/base.py
changeset 1516 8df06dc877aa
parent 1515 75de65fcb017
child 1517 a467d13e34ea
equal deleted inserted replaced
1515:75de65fcb017 1516:8df06dc877aa
   382     create_entity = not entity
   382     create_entity = not entity
   383 
   383 
   384     if create_entity:
   384     if create_entity:
   385       # entity did not exist, so create one in a transaction
   385       # entity did not exist, so create one in a transaction
   386       entity = self._model.get_or_insert(key_name, **properties)
   386       entity = self._model.get_or_insert(key_name, **properties)
   387 
   387     else:
   388 
   388       # If someone else already created the entity (due to a race), we
   389     # there is no way to be sure if get_or_insert() returned a new entity or
   389       # should not update the propties (as they 'won' the race).
   390     # got an existing one due to a race, so update with properties anyway,
   390       entity = self.updateEntityProperties(entity, properties, silent=True)
   391     # in a transaction
       
   392     entity = self.updateEntityProperties(entity, properties, silent=True)
       
   393 
   391 
   394     if create_entity:
   392     if create_entity:
   395       # a new entity has been created call _onCreate
   393       # a new entity has been created call _onCreate
   396       self._onCreate(entity)
   394       self._onCreate(entity)
   397     else:
   395     else: