Hi All, Table Categories:
categories_table = sa.Table('categories', connection.metadata) [categories_table.append_column(c) for c in ( sa.Column('id', sa.Integer, primary_key=True), sa.Column('name', sa.String(40)), sa.Column('flags', sa.SmallInteger), sa.Column('parent_id', sa.Integer, sa.ForeignKey('categories.id')))] sa.orm.mapper(Category, categories_table, properties={ 'subcategories' : sa.orm.relation(Category, backref=sa.orm.backref('_parent', remote_side=[categories_table.c.id])), }) c = Category() c.subcategories.append(Category()) # works great c._parent.append(Category()) # fails, c._parent is NoneType??? Why isn't _parent a list? This is actually a one-to-many so there is only one parent, but assigning doesn't work either: c._parent = Category() Traceback (most recent call last): File "C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.0beta5-py2.5.egg\sqlalchemy\orm\attributes.py", line 76, in __set__ File "C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.0beta5-py2.5.egg\sqlalchemy\orm\attributes.py", line 364, in set File "C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.0beta5-py2.5.egg\sqlalchemy\orm\attributes.py", line 300, in fire_replace_event File "C:\Program Files\Python\lib\site-packages\sqlalchemy-0.4.0beta5-py2.5.egg\sqlalchemy\orm\attributes.py", line 130, in sethasparent AttributeError: 'list' object has no attribute '_state' I want to be able to create the tree of Category() objects from the top down and set relations via _parent, but how can I do this? Thanks, -Dan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---