Advertisement
acoconut

Form question

Jul 20th, 2012
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. 292 class FormQuestion(object):
  2. 293     __storm_table__ = "form_question"
  3. 294     form_question_id = Int(primary = True,default = AutoReload)
  4. 295     content = Unicode()
  5. 296     user_id = Int()
  6. 297     version = Int()
  7. 298     question_id = Int()
  8. 299     status = Unicode()
  9. 300
  10. 301     def __init__(self,mlist):
  11. 302         self.mlist = mlist
  12. 303         self.database = getConn(mlist)
  13. 304
  14. 305     @decfunc
  15. 306     def recordAnswer(self, addr, question, answer, version):
  16. 307         """Save the answer for a question of the subscribe form, returning its id."""
  17. 308         subscriber = Subscriber(self.mlist)
  18. 310         userID = 1
  19. 311         status = "pending"
  20. 312         answer_unicode = answer.decode('utf-8')
  21. 314         command = "form_question = self.store.add(FormQuestion())\nform_question.content = answer_unicode\nform    _question.user_id = userID\nform_question.version = version\nform_question.question_id = question\nform_questio    n.status = status\n"
  22. 318         #form_question_id has autoreload set, its value will be serially updated in database
  23. 319         self.user_id = userID
  24. 320         self.content = answer_unicode
  25. 321         self.version = version
  26. 322         self.question_id = question
  27. 323         self.store.add(self)
  28. 324         formQuestionID = self.store.find(FormQuestion).max(FormQuestion.form_question_id)
  29. 327         return formQuestionID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement