The reason I do this "whacky" scheme is a simple content management system. Take this hirarchy for instance:
content page linklist productlist product someproduct So I can identify each content item by a unique id, and content is also type tagged. Of course a linklist should reference pages in a many to many relationship. Actually I think once people get their head around ORM mapping techniques and OO design you'll see a lot more of this pattern. Quoting Michael Bayer <[EMAIL PROTECTED]>: > the issue here is that your inheritance and your related table are > both to the same table, i.e. 'foo'. the logic that is breaking is > where it tries to determine "which property must be synchronized > between parent and child object, or between parent, child, and > association table", since honestly i never anticipated that the same > table would be represented in two different but related mappers in > quite that way. > > i am sure i'll come up with a patch for this one but i wonder if > people will still be coming up with these wacky scenarios a year from > now.... > > On Feb 25, 2006, at 6:37 PM, Florian Boesch wrote: > > > I require that kind of thing, so I've assembled a little testcode > > to demonstrate > > the problems. > > > > Below is the vanilla many to many thing that doesn't error upon > > defintion (with > > one minor glitch at the mapper, see #comments) > > > > from sqlalchemy import * > > from sqlalchemy.ext.proxy import ProxyEngine > > engine = ProxyEngine() > > > > foo = Table('foo', engine, > > Column('id', Integer, primary_key=True)) > > > > bar = Table('bar', engine, > > Column('id', Integer, primary_key=True)) > > > > foo_bar = Table('foo_bar', engine, > > Column('foo_id', Integer, ForeignKey('foo.id')), > > Column('bar_id', Integer, ForeignKey('bar.id'))) > > > > class Foo(object): pass > > Foo.mapper = mapper(Foo, foo) > > class Bar(object): pass > > Bar.mapper = mapper(Bar, bar) > > > > # Bar.mapper.add_property('foos', relation(Foo, foo_bar)) > > # ==> sqlalchemy.exceptions.ArgumentError: relation(class, table, > > **kwargs) is > > # deprecated. Please use relation(class, **kwargs) or relation > > (mapper, > > **kwargs). > > > > Bar.mapper.add_property('foos', relation(Foo.mapper, foo_bar)) > > > > > > Now when I throw in inheritance as in > > > > bar = Table('bar', engine, > > Column('id', Integer, ForeignKey('foo.id'), primary_key=True)) > > Bar.mapper = mapper(Bar, bar, inherits=Foo.mapper) > > > > and then try to > > Bar.mapper.add_property('foos', relation(Foo.mapper, foo_bar)) > > > > I get: > > Traceback (most recent call last): > > File "testalchemy.py", line 23, in ? > > Bar.mapper.add_property('foos', relation(Foo.mapper, foo_bar)) > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/mapping/mapper.py", > > line 195, in add_property > > prop.init(key, self) > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/mapping/mapper.py", > > line 777, in init > > self.do_init(key, parent) > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/mapping/properties.py", > > line 191, in do_init > > self._compile_synchronizers() > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/mapping/properties.py", > > line 583, in _compile_synchronizers > > self.primaryjoin.accept_visitor(processor) > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/sql.py", > > line 749, in accept_visitor > > c.accept_visitor(visitor) > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/sql.py", > > line 819, in accept_visitor > > visitor.visit_binary(self) > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/mapping/properties.py", > > line 969, in visit_binary > > self.func(binary) > > File > > "/usr/local/lib/python2.4/site-packages/SQLAlchemy-0.1.2-py2.4.egg/ > > sqlalchemy/mapping/properties.py", > > line 575, in compile > > raise AssertionError("assert failed") > > sqlalchemy.exceptions.AssertionError: assert failed > > > > (a sidenote, assert failed isn't a very clever assert line :D) > > > > ----- End forwarded message ----- > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a groundbreaking scripting > > language > > that extends applications into web and mobile media. Attend the > > live webcast > > and join the prime developer group breaking into this new coding > > territory! > > http://sel.as-us.falkag.net/sel? > > cmd=lnk&kid=110944&bid=241720&dat=121642 > > _______________________________________________ > > Sqlalchemy-users mailing list > > Sqlalchemy-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users > > ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users