Posted By

tamuratetsuya on 12/11/08


Tagged

google python engine app django


Versions (?)

Transactionについて 2


 / Published in: Python
 

  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  

You need to login to post a comment.