Transactionについて


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



Copy this code and paste it in your HTML
  1. class MyModel1(db.Model):
  2. text = db.StringProperty()
  3. anotherModelInfo = db.NumberProperty()
  4. class MyModel2(db.Model):
  5. ref = db.ReferenceProperty(MyModel1)
  6.  
  7. class Controller(webapp.RequestHandler):
  8. def post(self):
  9. datas = []
  10. ... # MyModelのlistであるdatasを作成。
  11. db.run_in_transaction(self.insert, datas)
  12.  
  13. def insert(datas):
  14. for data in datas:
  15. data.put()

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.