1 from storm.locals import *
2 database = create_database("mysql:uniphone")
3 store = Store(database)
6 __storm_table__ = "people"
9 phone_number = Unicode()
11 def __init__(self, **kw):
12 self.name = unicode(kw['name'])
13 self.phone_number = unicode(kw['phone_number'])
15 class Questionaire(object):
16 __storm_table__ = "questionaires"
17 id = Int(primary=True)
19 description = Unicode()
21 def __init__(self, **kw):
22 self.code = unicode(kw['code'])
23 self.description = unicode(kw['description'])
25 class Question(object):
26 __storm_table__ = "questions"
27 id = Int(primary=True)
32 questionaire_id = Int()
33 questionaire = Reference(questionaire_id, Questionaire.id)
35 def __init__(self, **kw):
36 self.code = unicode(kw['code'])
37 self.longdesc = unicode(kw['longdesc'])
38 self.shortdesc = unicode(kw['shortdesc'])
39 self.datatype = unicode(kw['datatype'])
40 self.questionaire_id = int(kw['questionaire_id'])
43 __storm_table__ = "answers"
44 id = Int(primary=True)
48 question = Reference(question_id, Question.id)
50 person = Reference(people_id, Person.id)
52 def __init__(self, **kw):
53 self.answer = unicode(kw['answer'])
54 self.received = unicode(kw['received']) # have this change to the right type
56 # define the many to one relationships
57 Person.answers = ReferenceSet(Person.id, Answer.id)
58 Questionaire.questions = ReferenceSet(Questionaire.id, Question.questionaire_id)
59 Question.answers = ReferenceSet(Question.id, Answer.id)