app/soc/logic/models/base.py
changeset 1514 4a233f5a4264
parent 1513 13efb916a73c
child 1515 75de65fcb017
equal deleted inserted replaced
1513:13efb916a73c 1514:4a233f5a4264
   298 
   298 
   299     Raises:
   299     Raises:
   300       out_of_band.Error if no entity is found
   300       out_of_band.Error if no entity is found
   301     """
   301     """
   302 
   302 
   303     key_fields = self.getKeyFieldsFromFields(fields)
   303     entity = self.getFromKeyFields(fields)
   304 
       
   305     entity = self.getFromKeyFields(key_fields)
       
   306 
   304 
   307     if entity:
   305     if entity:
   308       return entity
   306       return entity
   309 
   307 
   310     format_text = ugettext('"%(key)s" is "%(value)s"')
   308     format_text = ugettext('"%(key)s" is "%(value)s"')
   401     """See updateEntityProperties.
   399     """See updateEntityProperties.
   402 
   400 
   403     Like updateEntityProperties(), but not run within a transaction.
   401     Like updateEntityProperties(), but not run within a transaction.
   404     """
   402     """
   405 
   403 
   406     properties = entity.properties()
   404     properties = self._model.properties()
   407 
   405 
   408     for prop in properties.values():
   406     for name, prop in properties.iteritems():
   409       name = prop.name
   407       # if the property is not updatable or is not updated, skip it
   410 
   408       if name in self._skip_properties or (name not in entity_properties):
   411       if not name in self._skip_properties and name in entity_properties:
   409         continue
   412         value = entity_properties[prop.name]
   410 
   413 
   411       if self._updateField(entity, name, value):
   414         if self._updateField(entity, name, value):
   412         prop.__set__(entity, value)
   415           prop.__set__(entity, value)
       
   416 
   413 
   417     entity.put()
   414     entity.put()
   418     return entity
   415     return entity
   419 
   416 
   420   def updateOrCreateFromKeyName(self, properties, key_name):
   417   def updateOrCreateFromKeyName(self, properties, key_name):