app/soc/logic/models/expando_base.py
changeset 2736 8f3935f0f4ba
parent 2481 031e5828f3a4
child 3036 c703f3802841
equal deleted inserted replaced
2735:74f0972f523f 2736:8f3935f0f4ba
    37     super(Logic, self).__init__(model=model, base_model=base_model,
    37     super(Logic, self).__init__(model=model, base_model=base_model,
    38                                 scope_logic=scope_logic, name=name,
    38                                 scope_logic=scope_logic, name=name,
    39                                 skip_properties=skip_properties,
    39                                 skip_properties=skip_properties,
    40                                 id_based=id_based)
    40                                 id_based=id_based)
    41 
    41 
    42   def updateEntityProperties(self, entity, entity_properties, silent=False):
    42   def updateEntityProperties(self, entity, entity_properties, silent=False,
       
    43                              store=True):
    43     """Update existing entity using supplied properties.
    44     """Update existing entity using supplied properties.
    44 
    45 
    45     Overwrites base because of Expando properties.
    46     Overwrites base because of Expando properties.
    46 
    47 
    47     Args:
    48     Args:
    48       entity: a model entity
    49       entity: a model entity
    49       entity_properties: keyword arguments that correspond to entity
    50       entity_properties: keyword arguments that correspond to entity
    50         properties and their values
    51         properties and their values
    51       silent: iff True does not call _onUpdate method
    52       silent: iff True does not call _onUpdate method
    52 
    53       store: iff True updated entity is actually stored in the data model 
       
    54       
    53     Returns:
    55     Returns:
    54       The original entity with any supplied properties changed.
    56       The original entity with any supplied properties changed.
    55     """
    57     """
    56 
    58 
    57     if not entity:
    59     if not entity:
    66         continue
    68         continue
    67 
    69 
    68       if self._updateField(entity, entity_properties, name):
    70       if self._updateField(entity, entity_properties, name):
    69         setattr(entity, name, value)
    71         setattr(entity, name, value)
    70 
    72 
    71     entity.put()
    73     if store:
       
    74       entity.put()
    72 
    75 
    73     # call the _onUpdate method
    76     # call the _onUpdate method
    74     if not silent:
    77     if not silent:
    75       self._onUpdate(entity)
    78       self._onUpdate(entity)
    76 
    79