I'm trying to do a few (maybe too) clever things to make SQLA declarative relations less verbose for the most common cases, especially for when two relations to the same type exist, and therefore a 'primaryjoin' on the relationship is normally required. So with kemi's DeclarativeMeta, you can write this and it'll add the foreign keys and primaryjoins for you:
class Customer(Base): name = Column(String) billing_address = relationship("Address") shipping_address = relationship("Address") My implementation for this works OK _until_ some class defines its own table name, e.g.: class Address(Base): __tablename__ = 'myaddresses' By default, I convert the class name to lower case and use that for a table name. For this default case, I'm able to derive the column for the ForeignKey that I need to create, so with a relationship("Address") I would assume a ForeignKey("address.id"). What I'm looking for is a more robust way of getting the table name. When the class itself is passed to relationship(Address), that's not an issue, but what if I only have the name of the class and that class is not inside the class registry yet? Is there maybe an event that I can use to finalize my ForeignKey target fullnames? kemi's code has a test that illustrates the problem: https://github.com/dnouri/kemi/blob/master/kemi/test.py#L101 (Also, any thoughts that you might have on kemi's approach as a whole -- maybe someone already did this, please let me know.) Cheers, Daniel -- http://danielnouri.org -- 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.