Hi all,
i have an entity Question with a ManyToMany relationship answer_codes.
In an @before_insert or @after_insert, I'd like to add answer codes to
the answer_codes relationship. When I then flush or commit the
question is inserted into the database, the answer code relationship
entities however are not (the answer code entities already exist in
the database). Did I do something wrong or is this supposed to be like
that?
class Question(Entity):
...
answer_codes = ManyToMany('AnswerCode',
tablename='rel_question_to_answer_code',
onupdate='CASCADE',
ondelete='CASCADE')
@before_insert
def add_answer_codes(self):
for answer_code in self.valid_answer_codes:
self.answer_codes.append(AnswerCode.get_by
(code=answer_code))
Cheers,
Lea
--
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected].
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=.