more workaround for API breakage
authorAdam Glasgall <adam@crossproduct.net>
Fri, 22 Mar 2013 05:50:15 +0000 (22:50 -0700)
committerAdam Glasgall <adam@crossproduct.net>
Fri, 22 Mar 2013 05:50:15 +0000 (22:50 -0700)
debian/changelog
python/database/record.py
scripts/invirt-quota

index c644b4d..31a68a9 100644 (file)
@@ -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 <glasgall@mit.edu>  Thu, 21 Mar 2013 22:48:32 -0700
+
 invirt-database (0.2.8~glasgall8) precise; urgency=low
 
   * More API updates
index bcf3d45..fc8fa7f 100755 (executable)
@@ -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):
index f0fb16f..1efdae6 100755 (executable)
@@ -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