Renamed the association_proxy now that I understand how it works and
what I was doing wrong. I ended up with
model/cms.py:
class Template(Base):
__tablename__ = 'm_template'
id = Column(mysql.BIGINT(20, unsigned=True), primary_key=True,
autoincrement=True)
name = Column(Unicode(80))
blocks = relation(Block, secondary=Template_block,
collection_class=attribute_mapped_collection('name'))
class Page(Base):
__tablename__ = 'm_page'
id = Column(mysql.BIGINT(20, unsigned=True), primary_key=True,
autoincrement=True)
template_id = Column(mysql.BIGINT(20, unsigned=True),
ForeignKey(Template.id))
slug = Column(Unicode(80))
title = Column(Unicode(80))
template = relation(Template, uselist=False)
blocks = association_proxy('template', 'blocks')
Since I still need to expose template.name for rendering, but I want
to pass through Template to get to blocks, it seemed like the only way
I could still access Page -> Template.name
At the same time I ran into another issue with Base.metadata.
Block_element = Table('m_block_element', Base.metadata,
Column('block_id', Integer, ForeignKey('m_block.id')),
Column('element_id', Integer, ForeignKey('m_element.id')),
Column('sorttree', Integer)
)
class Block(Base): __tablename__ = 'm_block'
id = Column(mysql.BIGINT(20, unsigned=True), primary_key=True,
autoincrement
=True)
name = Column(Unicode(80))
#elements = relation('Element', secondary=Block_element)
elements = relation('Element', secondary=Block_element,
order_by='m_block_element.sorttree')
results in AttributeError: 'Table' object has no attribute 'sorttree'
If I reference order_by=Block_element.sorttree, paster crashes with
the same error.
--
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.