I'd remove the redundant foreign key constraints:

tasks_contacts_table = Table('tasks_contacts', meta,
    Column('id', Integer, primary_key=True),
    Column('contact_id', Integer, ForeignKey(person_table.c.id, 
ondelete="CASCADE"), index=True),
    Column('task_id', Integer, ForeignKey(tasks_table.c.id, 
ondelete="CASCADE"), index=True),
    UniqueConstraint('contact_id', 'task_id'),
    mysql_engine='InnoDB',
    mysql_charset='utf8'
    )


and the mapping can be simple:

mapper(Task, tasks_table, properties={
    'type': relationship(TaskType),
    'contacts': relationship(Person, 
        secondary=tasks_contacts_table)})


Otherwise it's fine and there's nothing illustrated that would show a "can't 
set attribute" condition.   That would occur if you're trying to assign to an 
attribute that's handled by a read-only @property.


On Jul 23, 2011, at 3:53 AM, Vitaly Volkov wrote:

> Hello
> 
> When I am trying to create relationship for Many-To-Many, I get an
> error "can't set attribute".
> Here is my database structure - http://pastebin.com/0m31ULH9 . Could
> please somebody say where I make a mistake with that? I am new in
> sqlalchemy.
> 
> 
> Regards.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to