Argh yes you're right. Thank you. Julien.
On Tue, Sep 28, 2010 at 11:57 PM, Michael Bayer <mike...@zzzcomputing.com> wrote: > > On Sep 28, 2010, at 5:50 PM, Julien Iguchi-Cartigny wrote: > >> Hi, >> >> I'm trying to declare a adjacency list as follow: >> >> class CourseSet(AbstractContainer): >> parent_id = Column('PARENT_COURSE_SET', Integer, >> ForeignKey('CM_MEMBER_CONTAINER_T.ENTERPRISE_ID')) >> children = relationship("CourseSet", backref=backref('parent', >> remote_side=AbstractNamed.eid)) > > OK sorry, you're really working the mixins to the Nth degree here. The > columns that are on CourseSet are relative to the mapped class. The > Column() object on AbstractNamed gets copied when declarative sees it. So > the correct column to place on "remote_side" would be AbstractContainer.eid, > since AbstractContainer is the class that's mapped to the table which > contains "ENTERPRISE_ID". > > > > >> >> �...@classproperty >> def __mapper_args__(self): >> args = dict() >> args.update(AbstractContainer.__mapper_args__) >> args.update({'polymorphic_identity': >> 'org.sakaiproject.coursemanagement.impl.CourseSetCmImpl'}) >> return args >> >> But I couldn't succeed, i've the following error message: >> >> sqlalchemy.exc.ArgumentError: Relationship CourseSet.parent could not >> determine any local/remote column pairs from remote side argument >> set([Column('ENTERPRISE_ID', String(length=255, convert_unicode=False, >> assert_unicode=None, unicode_error=None, >> _warn_on_bytestring=False), )]) >> >> I've tried to use >> http://www.sqlalchemy.org/docs/orm/relationships.html#adjacency-list-relationships >> but with no success. The only "not-classical" thing is the use of >> AbstractNamed.eid (a field from a parent class), is there an impact ? >> >> Cheers, >> >> Julien. >> >> PS: other parent objects: >> >> class AbstractPersistent(object): >> version = Column('VERSION', Integer) >> last_modified_by = Column('LAST_MODIFIED_BY', String(255)) >> last_modified_date = Column('LAST_MODIFIED_DATE', Date) >> created_by = Column('CREATED_BY', String(255)) >> created_date = Column('CREATED_DATE', Date) >> >> def __repr__(self): >> return "<AbstractPersistent('%s','%s', '%s','%s','%s')>" % \ >> (self.version, self.last_modified_by, >> self.last_modified_date, >> self.created_by, self.created_date) >> >> class AbstractNamed(AbstractPersistent): >> eid = Column('ENTERPRISE_ID', String(255)) >> title = Column('TITLE', String(255)) >> description = Column('DESCRIPTION', String(255)) >> >> def __repr__(self): >> return "<AbstractNamed('%s','%s', '%s')>" % \ >> (self.eid, self.title, self.description) + \ >> super(AbstractNamed, self).__repr__() >> >> >> class AbstractContainer(Base,AbstractNamed): >> __tablename__ = 'CM_MEMBER_CONTAINER_T' >> id = Column('MEMBER_CONTAINER_ID',Integer,primary_key=True) >> discriminator = Column('CLASS_DISCR', String(100)) >> __mapper_args__ = {'polymorphic_on': discriminator } >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To post to this group, send email to sqlalch...@googlegroups.com. >> To unsubscribe from this group, send email to >> sqlalchemy+unsubscr...@googlegroups.com. >> 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 sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- "Trouble-a-cat limited" -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.