thanks for the confirmation!

On Nov 13, 12:43 pm, GAEfan <ken...@gmail.com> wrote:
> Baron:
>
> That is exactly what key names are for.  You can write over the same
> entity (it has to have the same key name to be the same entity), and
> no harm done.  Or, if the key doesn't exist, create the entity.  The
> put() does both.
>
> thisEntity = thisModel.get_by_key_name('thisKey')
> if not thisEntity:
>   thisEntity = thisModel(key_name='thisKey', trait1='hey',
> trait2='there', etc.)
>   thisEntity.put()
> else:
>   thisEntity.trait1 = 'changed to hello'  (if you need to change
> anything)
>   thisEntity.put()
>
> If you put the records again, there will not be duplicates, as the
> key_name is unique.
>
> Bottom line:  Don't make any model without creating an easy-to-
> remember-and-call key_name.  It will come in handy some day.

--

You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appeng...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=.


Reply via email to