My model in test1 plugin
# -*- coding: utf-8 -*-
from sqlalchemy import Table, ForeignKey, Column
from sqlalchemy.types import Unicode, Integer, DateTime
from sqlalchemy.orm import backref, relation
from test1.model import DeclarativeBase
from tgext.pluggable import app_model, primary_key
from sicer.model import metadata
class Tag(DeclarativeBase):
__tablename__ = 'tag'
id = Column(Integer, autoincrement=True, primary_key=True)
text= Column(Unicode(200))
class Article(DeclarativeBase):
__tablename__ = 'article'
id = Column(Integer, autoincrement=True, primary_key=True)
text= Column(Unicode(2000) )
tags = relation(Tag, secondary=lambda: tag_article, backref='articles')
tag_article= Table('tag_article', metadata,
Column('tag_id', Integer, ForeignKey(Tag.id), primary_key=True),
Column('article_id', Integer, ForeignKey(Article.id), primary_key=True))
Il giorno giovedì 18 aprile 2013 16:53:52 UTC+2, Alessandro Molina ha
scritto:
>
> What is it "metadata" you use in tag_article Table definition? Might it be
> that the two tables are registered in different metadata?
>
>
> On Thu, Apr 18, 2013 at 4:34 PM, Luca Verardi
> <[email protected]<javascript:>
> > wrote:
>
>> I'm getting an error even with lambda.
>>
>> sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation "article"
>> does not exist
>> '\nCREATE TABLE tag_article (\n\ttag_id INTEGER NOT NULL, \n\tarticle_id
>> INTEGER NOT NULL, \n\tPRIMARY KEY (tag_id, article_id), \n\tFOREIGN
>> KEY(tag_id) REFERENCES tag (id), \n\tFOREIGN KEY(article_id) REFERENCES
>> article (id)\n)\n\n' {}
>>
>> The tables I'm declaring have nothing to do with the main project
>>
>>
>> class Tag(DeclarativeBase):
>> __tablename__ = 'tag'
>>
>> id = Column(Integer, autoincrement=True, primary_key=True)
>> text= Column(Unicode(200))
>>
>> class Article(DeclarativeBase):
>> __tablename__ = 'article'
>>
>> id = Column(Integer, autoincrement=True, primary_key=True)
>> text= Column(Unicode(2000) )
>>
>> tags = relation(Tag, secondary=lambda: tag_article,
>> backref='articles')
>>
>>
>> tag_article= Table('tag_article', metadata,
>>
>> Column('tag_id', Integer, ForeignKey(Tag.id), primary_key=True),
>> Column('article_id', Integer, ForeignKey(Article.id),
>> primary_key=True))
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "TurboGears" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/turbogears?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.