Transactionについて 2


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. class MyModel1(db.Model):
  2. title = StringProperty()
  3. class MyModel2(db.Model):
  4. ref = ReferenceProperty(MyModel1)
  5. otherRef = ReferenceProperty(OtherModel)
  6.  
  7. def method():
  8. model1 = MyModel1.get_by_id(int(idString))
  9. model2s = MyModel2.gql("WHERE ref = :ref", ref=model1)
  10. db.run_in_transaction(delete_cascade, model1, model2s)
  11.  
  12. def delete_cascade(model1, model2s)
  13. db.delete(model2s)
  14. model1.delete()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.