Changes to AppEngine's _from_entity

Both my blog and Enstore experienced a serious outage today. This was caused by a recent change to how App Engine initializes entities. The error was:

BadArgumentError: Cannot use key and key_name at the same time with different values

A common trick to detect wether an entity is loaded from datastore or not is to check if kwargs.get('_from_entity') == True: in the models __init__ method. Before today’s change _from_entity was a bool argument and this code worked perfectly. Today’s change made _from_entity a dictionary containing the entities’ properties and values. Because of this the explicit check for True returned False and both Enstore and this blog started returning 500 errors.

The issues were resolved by changing :

`if kwargs.get('_from_entity') == True:` 


`if kwargs.get('_from_entity'):`.

This project is maintained by klaaspieter