Hi,

Is it possible to have an association_proxy (in the association object
pattern) that emulates a set-based collection if it goes through a
lazy='dynamic' relationship? I can't for the life of me find a way to
make this work (setting collection_class on the dynamic relationship
doesn't seem to do anything).

Here's some example code of what I'm trying to do, extracted from the
actual project:

class ProofOfWork(object):
  blocks = association_proxy('Intermediatory_nodes', 'block')
proof_of_work = Table('proof_of_work', db.metadata)
mapper(ProofOfWork, proof_of_work, properties={
  'Intermediatory_nodes': relationship(lambda: Intermediatory,
    lazy = 'dynamic'),
})

class Block(object):
  proof_of_works = association_proxy('Intermediatory_nodes',
'proof_of_work')
block = Table('block', db.metadata)
mapper(Block, block, properties={
  'Intermediatory_nodes': relationship(lambda: Intermediatory,
    lazy = 'dynamic'),
})

class Intermediatory(object):
  pass
intermediatory = Table('intermediatory', db.metadata,
  Column('proof_of_work_id', Integer,
    ForeignKey('proof_of_work.id'),
    nullable = False),
  Column('block_id', Integer,
    ForeignKey('block.id')),
)
mapper(Intermediatory, intermediatory, properties={
  'proof_of_work': relationship(lambda: ProofOfWork,
    back_populates = 'Intermediatory_nodes',
    remote_side    = lambda: proof_of_work.c.id),
  'block': relationship(lambda: Block,
    back_populates = 'Intermediatory_nodes',
    remote_side    = lambda: block.c.id),
})

How can I make ProofOfWork.blocks and Block.proof_of_works return an
_AssociationSet instead of _AssociationList?

Cheers,
Mark

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@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.

Reply via email to