diff options
| author | Michael Manfre <mmanfre@gmail.com> | 2013-09-23 20:17:59 -0400 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-09-25 21:47:26 +0300 |
| commit | 99c87f1410106ce543a1a0332428afc472beef7f (patch) | |
| tree | ee2c17e7f246e842ede59c45af504209c036170d /docs/releases | |
| parent | 04a2a6b0f9cb6bb98edfe84bf4361216d60a4e38 (diff) | |
Fixed #17671 - Cursors are now context managers.
Diffstat (limited to 'docs/releases')
| -rw-r--r-- | docs/releases/1.7.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 6a29635d18..8dc17761b9 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -111,6 +111,25 @@ In addition, the widgets now display a help message when the browser and server time zone are different, to clarify how the value inserted in the field will be interpreted. +Using database cursors as context managers +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Prior to Python 2.7, database cursors could be used as a context manager. The +specific backend's cursor defined the behavior of the context manager. The +behavior of magic method lookups was changed with Python 2.7 and cursors were +no longer usable as context managers. + +Django 1.7 allows a cursor to be used as a context manager that is a shortcut +for the following, instead of backend specific behavior. + +.. code-block:: python + + c = connection.cursor() + try: + c.execute(...) + finally: + c.close() + Minor features ~~~~~~~~~~~~~~ |
