View AsciidocCheatsheet.adoc
Asciidoc cheatsheet for GitHub
View representable_base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# based on: https://gist.github.com/exhuma/5935162#file-representable_base-py | |
class RepresentableBase(object): | |
""" Add automatic __repr__ and __str__ to SQLAlchemy ORM models | |
""" | |
def _repr_worker(self, attribute): | |
mapper = object_mapper(self) | |
items = [(p.key, getattr(self, p.key)) | |
for p in ( | |
mapper.get_property_by_column(c) |