Thanks for the accurate answer, it have a lot of sense to have an add method but I didn't know that it existed.

2008/5/17 Oleg Broytmann <>:
On Sat, May 17, 2008 at 01:59:03AM +0200, Luis Javier Peris wrote:
> 'm working with SQLObject and I'm getting frustated because of lack of
> examples. First of all, I'm having problems creating tables with
> many-many relationships
> by means of RelatedJoin. I want to create and know how work the CRUD
> operations in the tables created by RelatedJoin operation. I have two tables
> I've created as follow:
> class Term(SQLObject):
>     name = StringCol(default=None)
>     description = StringCol(default=None)
>     vocabulary = ForeignKey('Vocabulary')
>     term_questions = RelatedJoin('Question', joinColumn='question',
> otherColumn='term',
>                                  intermediateTable='Term_questions')
> Term.createTable(ifNotExists=True)
> class Question(SQLObject):
>     question_file = StringCol(default=None, length=255, unique=True)
>     question_name = StringCol(default=None)
>     question_type = StringCol(default=None)
>     term_questions = RelatedJoin('Term', joinColumn='term',
> otherColumn='question',
>                                  intermediateTable='Term_questions')
> Question.createTable(ifNotExists=True)
> So, I have a new table with two columns (term and question). How CRUD
> operations work?
> I've tried to create a new instance of Term_questions table:
> Term_questions(,, but the module Term_questions
> doesn't exist

  It doesn't exist. If you want to explicitly declare it:

> or if I try:
> q = Question(question_file="file", question_name= "name",
> question_type="MultipleChoice")
> term.term_questions =
> I get: AttributeError: can't set attribute

  term.term_questions is a list. If want to add an object to the join, use
add*() methods:




    Oleg Broytmann    
          Programmers don't die, they just GOSUB without RETURN.

This email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
sqlobject-discuss mailing list