changeset 628:739720896d61

added get by id to api0
author James Bergstra <bergstrj@iro.umontreal.ca>
date Mon, 19 Jan 2009 18:34:13 -0500
parents ec27e19bb6eb
children 4e7781972999
files pylearn/dbdict/api0.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/dbdict/api0.py	Mon Jan 19 18:10:48 2009 -0500
+++ b/pylearn/dbdict/api0.py	Mon Jan 19 18:34:13 2009 -0500
@@ -485,6 +485,18 @@
 
     def session(h_self):
         return h_self._session_fn()
+
+    def get(h_self, id):
+        s = h_self.session()
+        rval = s.query(h_self._Dict).get(id)
+        if rval:
+            #eagerload hack
+            str(rval)
+            rval.id
+        s.close()
+        return rval
+
+
         
 
 def db_from_engine(engine,