]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
contextual_connection() -> contextual_connect() [ticket:515]
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Mar 2007 23:29:31 +0000 (23:29 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 20 Mar 2007 23:29:31 +0000 (23:29 +0000)
doc/build/content/dbengine.txt
doc/build/content/unitofwork.txt

index e20eb4250ac2d0a9a8a1f9dc4e31f6142219e48e..ae818ec03b2a6ad2054724799a26f40dd1e8fbcf 100644 (file)
@@ -326,19 +326,19 @@ Using the "threadlocal" strategy, all calls to `execute` within the same thread
     # are returned to the pool.
     r2 = None
 
-To get at the actual `Connection` object which is used by implicit executions, call the `contextual_connection()` method on `Engine`:
+To get at the actual `Connection` object which is used by implicit executions, call the `contextual_connect()` method on `Engine`:
 
     {python title="Contextual Connection"}
     # threadlocal strategy
     db = create_engine('mysql://localhost/test', strategy='threadlocal')
     
-    conn1 = db.contextual_connection()
-    conn2 = db.contextual_connection()
+    conn1 = db.contextual_connect()
+    conn2 = db.contextual_connect()
 
     >>> conn1.connection is conn2.connection
     True
 
-When the `plain` strategy is used, the `contextual_connection()` method is synonymous with the `connect()` method; both return a distinct connection from the pool.
+When the `plain` strategy is used, the `contextual_connect()` method is synonymous with the `connect()` method; both return a distinct connection from the pool.
 
 One programming pattern that the `threadlocal` strategy supports is transparent connection and transaction sharing.
 
@@ -351,13 +351,13 @@ One programming pattern that the `threadlocal` strategy supports is transparent
         
     def dosomethingelse():
         table2.execute("some sql")
-        conn = db.contextual_connection()
+        conn = db.contextual_connect()
         # do stuff with conn
         conn.execute("some other sql")
         conn.close()
     
     def dosomethingtransactional():
-        conn = db.contextual_connection()
+        conn = db.contextual_connect()
         trans = conn.begin()
          # do stuff
         trans.commit()
@@ -371,5 +371,5 @@ One programming pattern that the `threadlocal` strategy supports is transparent
     except:
         db.rollback()
 
-In the above example, the program calls three functions `dosomethingimplicit()`, `dosomethingelse()` and `dosomethingtransactional()`.  In all three functions, either implicit execution is used, **or** an explicit `Connection` is used via the `contextual_connection()` method.  This indicates that they all will share the same underlying dbapi connection as well as the same parent `Transaction` instance, which is created in the main body of the program via the call to `db.create_transaction()`.  So while there are several calls that return "new" `Transaction` or `Connection` objects, in reality only one "real" connection is ever used, and there is only one transaction (i.e. one begin/commit pair) executed.
+In the above example, the program calls three functions `dosomethingimplicit()`, `dosomethingelse()` and `dosomethingtransactional()`.  In all three functions, either implicit execution is used, **or** an explicit `Connection` is used via the `contextual_connect()` method.  This indicates that they all will share the same underlying dbapi connection as well as the same parent `Transaction` instance, which is created in the main body of the program via the call to `db.create_transaction()`.  So while there are several calls that return "new" `Transaction` or `Connection` objects, in reality only one "real" connection is ever used, and there is only one transaction (i.e. one begin/commit pair) executed.
 
index ddf4bbe473f65199dcbd35191806db7a57a18218..261799e41b43326660e911a72e1b588abd5c8273 100644 (file)
@@ -422,7 +422,7 @@ The other way is just to use the `Connection` referenced by the `SessionTransact
         raise
     trans.commit()
         
-The `connection()` method also exists on the `Session` object itself, and can be called regardless of whether or not a `SessionTransaction` is in progress.  If a `SessionTransaction` is in progress, it will return the connection referenced by the transaction.  If an `Engine` is being used with `threadlocal` strategy, the `Connection` returned will correspond to the connection resources that are bound to the current thread, if any (i.e. it is obtained by calling `contextual_connection()`).
+The `connection()` method also exists on the `Session` object itself, and can be called regardless of whether or not a `SessionTransaction` is in progress.  If a `SessionTransaction` is in progress, it will return the connection referenced by the transaction.  If an `Engine` is being used with `threadlocal` strategy, the `Connection` returned will correspond to the connection resources that are bound to the current thread, if any (i.e. it is obtained by calling `contextual_connect()`).
 
 #### Using Engine-level Transactions with Sessions