Support .get(fieldname) on sql db objects
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Sun, 25 Dec 2011 15:01:25 +0000 (16:01 +0100)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Wed, 28 Dec 2011 23:14:47 +0000 (00:14 +0100)
Some parts of the code like to call .get("somefield") on
the db objects.  It's easy to support this on sqlalchemy
based objects, so lets do it.

mediagoblin/db/sql/base.py

index 5e420bdc43856c39f43fd08a572695c2ad5a023b..1249bace0c34c685d0dd67fefa0b37de4705c173 100644 (file)
@@ -25,3 +25,6 @@ class GMGTableBase(object):
     @classmethod
     def one(cls, query_dict):
         return cls.find(query_dict).one()
+
+    def get(self, key):
+        return getattr(self, key)