On 04/03/11 10:01, Tomasz Zieliński wrote:
> On 2 Mar, 00:10, Jason Culverhouse <ja...@mischievous.org> wrote:
>> Hi,
>> It seems that the contenttype framework and the sites contribs
>> conflict with using the autocommit:True database option.  
> 
> Do you really need that autocommit? Django has its own concept of
> autocommit,
> which seems to just work most of the time.
> With database-level autocommit turned on, Django-level transaction
> handling
> is not going to do anything useful.
> 

Uhm. That's inaccurate in the postgresql case, IIRC. With the psycopg2
backend autocommit option on, if you /actually start a transaction/ via
django (n.b. _including_ implicitly via turning on the normal django
TransactionMiddleware*), you still get transactional behaviour.  It's
the initial/"outer" state is autocommit, which is useful for a variety
of reasons (the one that we've found most useful is "intuitive"
(conforming to naive user expectations) behaviour at the ./manage.py shell)

* The TransactionMiddleware calls enter_transaction_management [1][2],
which will boost the isolation level to 1 (from 0) if autocommit is on
for the psycopg2 backend. [3] (noting managed=True in [2]) .  If
autocommit is off, then the isolation level is 1 anyway. [4]
See psycopg2 docs for isolation level notes [5].  (I think django
sources could do with using the relevant psycopg2 constants for the
levels and not 0/1, but that's minor)

[1]
http://code.djangoproject.com/browser/django/trunk/django/middleware/transaction.py#L10

[2]
http://code.djangoproject.com/browser/django/trunk/django/db/transaction.py#L32

[3]
http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql_psycopg2/base.py#L172

[4]
http://code.djangoproject.com/browser/django/trunk/django/db/backends/postgresql_psycopg2/base.py#L109

[5] http://initd.org/psycopg/docs/extensions.html#isolation-level-constants

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to