Michael,

> 
> > class PressRoutingPress(Base):
> >    '''This class defines the many-to-many join table between press
> >    and press_routing.
> >    '''
> >    __tablename__ = "press_routing_press"
> >    __table_args__ = {'autoload' : True}
> >
> >    press_id = Column(Integer, ForeignKey('press.id'),
> > primary_key=True)
> >    press_routing_id = Column(Integer,
ForeignKey('press_routing.id'),
> > primary_key=True)
> >
> > class PressRouting(Base):
> >    '''This class defines the press_routing table information.
> >    '''
> >    __tablename__ = "press_routing"
> >    __table_args__ = {'autoload' : True}
> >
> > class Press(Base):
> >    '''This class defines the press table information.
> >    '''
> >    __tablename__ = "press"
> >    __table_args__ = {'autoload' : True}
> >
> >    # many to many Press<->PressRouting
> >    press_routing = relation('PressRouting',
> >                             secondary=PressRoutingPress,
> >
> > primaryjoin=id==PressRoutingPress.press_id,
> >
> foreign_keys=[PressRoutingPress.press_id],
> >
> > secondaryjoin=PressRouting.id==PressRoutingPress.press_routing_id,
> >
> > foreign_keys=[PressRoutingPress.press_routing_id],
> >                             uselist=False)
> >                             #backref=backref('press'))
> >                             #viewonly=True)
> >
> > This all works till I try to instantiate an instance of a Press()
> > object, then I get the following exception:
> 
> when you use the "secondary" argument on relation(), that should be a
> plain Table object and should not be mapped (i.e. there should be no
> separate class for it):
> 
> press_routing_press = Table("press_routing_press", Base.metadata,
>       Column("press_id", Integer, ForeignKey('press.id'),
> primary_key=True),
>       Column("press_routing_id", Integer,
> ForeignKey('press_routing.id'),primary_key=True)
> )
> 
> class Press(Base):
>      ...
> 
>      press_routing = relation("PressRouting",
> secondary=press_routing_press)
> 
> no other arguments to relation() are needed.
> 
> If you do want PressRoutingPress to be mapped, you use the association
> object pattern, which means you aren't using the "secondary" keyword.
> The non-declarative version is here:
>
http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_relation_
> patterns_association
> 

I implemented your suggestion and that cleared things right up, and made
the set up code much simpler. Thanks for your help, considering how much
time you spend answering questions, I really appreciate your attention
to my issues!

Thanks again,
Doug

--~--~---------~--~----~------------~-------~--~----~
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