Tomer Weller
Tomer Weller

Reputation: 2812

appengine DateTimeProperty auto_now=True unexpected behavior

I use a last_touch_date DateTimeProperty as a means for revisioning entities in my application's datastore using the auto_now=True flag. When a user posts an entity it receives its last_touch_date as a reference for future updates.

However, when I check the entity's last_touch_date afterwards I always find a slight delta between this property as read right after writing and soon afterwards. I have a feeling this is a result of the high consistency model.

Is this known behavior? Is there a workaround besides managing this property my self?

Upvotes: 1

Views: 341

Answers (1)

Guido van Rossum
Guido van Rossum

Reputation: 16890

No, this is not due to the HRD -- auto_now is implemented purely in the client library. After you write the entity, the property's value does not correspond to what's written to the datastore, but to what was last read. I'm not sure what you'll see for a brand new entity but it's probably still not the same as what was written.

If you switch to NDB you'll find that auto_now behaves much more reasonably. :-)

Upvotes: 2

Related Questions