Edgewall Software

Changes between Version 35 and Version 36 of TracDev/ApiChanges/0.12


Ignore:
Timestamp:
Jun 1, 2010, 9:51:42 AM (14 years ago)
Author:
Christian Boos
Comment:

#get_db_cnx deprecation

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/ApiChanges/0.12

    v35 v36  
    4545
    4646=== Other Changes ===
     47
     48==== `Environment.get_db_cnx` is deprecated #get_db_cnx
     49
     50Due to the new support for automated transaction management, `Connection` instances should no longer be acquired using the familiar `get_db_cnx` method, as it doesn't tell whether the connection will be used as part of a write transaction or purely for queries. Instead, one should use:
     51 - `env.get_read_db` for obtaining a `Connection` suitable for read queries (i.e. `SELECT`)
     52 - the `env.with_transaction` decorator, for using a `db` parameter in a transaction function which should be committed  when the last such automatic transaction in the control flow completes successfully (see [#with_transaction details] further down)
     53
     54Using `env.get_db_cnx` still works, but any explicit transaction management will risk to prematurely end a higher level transaction set up via `with_transaction` at a previous level in the control flow.
    4755
    4856==== `prevnext_nav` support for i18n ^[source:trunk/trac/web/chrome.py@8597:158-164#L158 (0.12)] [source:branches/0.11-stable/trac/web/chrome.py@8550:139-144#L139 (0.11)]^ ==== #prevnext_nav
     
    247255Implementing this mechanism as a function decorator is an intermediate solution until the `with` statement and context managers become available (once we drop support for Python 2.4).
    248256
    249 See #8751 for details.
     257See #8751 for details and related notes about [#get_db_cnx get_db_cnx] deprecation above.