Thursday, 15 August 2013

python - How to check whether someone changed the entity data -



python - How to check whether someone changed the entity data -

for example, "transaction table" entities editable users. how can check, changed , updated same entity ?

if understood problem correctly want create sure if 2 people editing same entity, 1 of them shouldn't able save.

first of it's thought have base of operations class models these 2 properties beingness updated automatically:

class base(ndb.model): created = ndb.datetimeproperty(auto_now_add=true) modified = ndb.datetimeproperty(auto_now=true)

now having modified property in model helps lot on noticing if changed (by else) during update:

before editing read modified property , store in before_modified before saving read modified property , compare before_modified if these 2 values same it's safe save, otherwise notify user entity has been changed else

python google-app-engine

No comments:

Post a Comment