Browse Source

Fancy monkey patching ...

 * add method to list all results
   we wantz diz ...
Oz N Tiram 9 years ago
parent
commit
07ed2c845c
1 changed files with 16 additions and 0 deletions
  1. 16 0
      frank/frank.py

+ 16 - 0
frank/frank.py

@@ -121,6 +121,22 @@ from shell import Shell
 from collections import OrderedDict, namedtuple
 import importlib
 from conf import taskq
+import types
+
+# monkey patch data store
+_list = "select * FROM {0}"
+
+def list_results(obj):
+    with obj._db.get_connection() as conn:
+        try:
+            return list(conn.execute(obj._list.format(obj.name)))
+        except:
+            return None
+
+
+taskq.result_store._list = _list
+taskq.result_store.list_results = types.MethodType(list_results,
+                                                   taskq.result_store)
 
 PythonCode = namedtuple('PythonCode', ['path', 'args', 'kwargs', 'code'])