From: Adam Glasgall Date: Fri, 22 Mar 2013 05:50:15 +0000 (-0700) Subject: more workaround for API breakage X-Git-Tag: 0.2.9~8 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-database.git/commitdiff_plain/df7d9b424e94c763b4180526a6eac4912c558432 more workaround for API breakage --- diff --git a/debian/changelog b/debian/changelog index c644b4d..31a68a9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +invirt-database (0.2.8~glasgall9) precise; urgency=low + + * SQLAlchemy no longer injects a .c attribute containing mapped fields + into mapped classes. Work around this by getting the mapped table from + sqlalchemy and asking it for columns + + -- Adam Glasgall Thu, 21 Mar 2013 22:48:32 -0700 + invirt-database (0.2.8~glasgall8) precise; urgency=low * More API updates diff --git a/python/database/record.py b/python/database/record.py index bcf3d45..fc8fa7f 100755 --- a/python/database/record.py +++ b/python/database/record.py @@ -1,3 +1,5 @@ +import sqlalchemy.orm.util as util + class Record(object): _identity_field = None _default = {} @@ -28,7 +30,7 @@ class Record(object): def _fields(self): ignore = self._ignore() - keys = sorted(self.c.keys()) + keys = sorted(util.class_mapper(type(self)).mapped_table.c.keys()) return [(k,self._formatField(k)) for k in keys if k not in ignore] def __repr__(self): diff --git a/scripts/invirt-quota b/scripts/invirt-quota index f0fb16f..1efdae6 100755 --- a/scripts/invirt-quota +++ b/scripts/invirt-quota @@ -47,7 +47,7 @@ def main(argv): database.connect() database.session.begin() - owner = database.Owner.query().filter_by(owner_id=owner_id).first() + owner = database.session.query(database.Owner).filter_by(owner_id=owner_id).first() if owner is None: owner = database.Owner(owner_id=owner_id) @@ -57,6 +57,7 @@ def main(argv): val = getattr(opts, resource+scope) if val is not None: setattr(owner, resource+'_quota_'+scope, val if val >= 0 else None) + database.session.add(owner) database.session.commit() print owner