I'm writing some code to serialize some SA models to JSON, and for columns and relationships, it's convenient to tag which fields should be serialized with the info dictionary like so:
class Thing(Base): id = Column(Integer, primary_key=True, info={'jsonify': False}) name = Column(String, info={'jsonify': True}) relationship(SomeModel, info={'jsonify': True} Then in the Base class, you can iterate over properties like: for attr, column in inspect(self.__class__).columns.items(): if column.info.get('jsonify', False): json_output[attr] = getattr(self, attr) for attr, rel in inspect(self.__class__).relationships.items(): # similar, with some recursion depending on rel.uselist etc... But for association_proxies, there is no info property, nor is there any mapper.association_proxies attribute. I can obviously hack around this in some way, but I'm wondering if I'm going about it wrong. Is the best way to get the association_proxies from the mapper to filter through .all_orm_descriptors? Also, why don't association_proxies have an info property? What would be the recommended way to do this kind of annotation on the models for json serialization? -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.