]> git.saurik.com Git - cyql.git/commitdiff
Generalize context as argument to execute().
authorJay Freeman (saurik) <saurik@saurik.com>
Thu, 13 Jan 2011 06:03:13 +0000 (06:03 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Thu, 13 Jan 2011 06:03:13 +0000 (06:03 +0000)
__init__.py

index 944869580e1161cdc91ea15d9e39a72e875b860e..8ac73cf9320f1f978a071784770d1db836174eb3 100644 (file)
@@ -31,12 +31,14 @@ class connection(object):
             yield cursor
 
     @contextmanager
-    def execute(self, statement, depth=0):
+    def execute(self, statement, depth=0, context=None):
         with self.cursor() as cursor:
             # two frames, accounting for execute() and @contextmanager
             locals = inspect.currentframe(depth + 2).f_locals
             try:
-                cursor.execute(statement.format(**locals), locals)
+                if context == None:
+                    context = locals
+                cursor.execute(statement.format(**locals), context)
             finally:
                 del locals
             yield cursor