Created
December 29, 2012 20:43
-
-
Save ThiefMaster/4409236 to your computer and use it in GitHub Desktop.
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
def from_sqlalchemy(self, obj) | |
from sqlalchemy.orm import class_mapper, ColumnProperty | |
columns = [prop.key for prop in class_mapper(obj.__class__).iterate_properties | |
if isinstance(prop, ColumnProperty)] | |
for column in columns: | |
if column in self: | |
self[column].data = getattr(obj, column) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment