foreign_to_a = Column(UnicodeText)
maximum_a = relationship(A, secondary=latest_a, primaryjoin=latest_a.c.
    a_remote == foreign_to_a, secondaryjoin=latest_a.c.a_id == A.a_id,
    uselist=False, viewonly=True)
Correlating a SQLAlchemy relationship with an awkward join