Fwd: Re: TransactionMiddleware and SessionMiddleware

2008-12-10 Thread Tim Sawyer

On Wednesday 10 December 2008 16:46:36 Thomas Guettler wrote:
> Hi,
>
> I follow: http://docs.djangoproject.com/en/dev/topics/db/transactions/
> {{{
> The order is quite important. The transaction middleware applies not
> only to view functions, but also for all middleware modules that come
> after it. So if you use the session middleware after the transaction
> middleware, session creation will be part of the transaction.
> }}}
>
> # settings.py
> MIDDLEWARE_CLASSES = [
>
> 'djangotools.middleware.HandleExceptionMiddleware.HandleExceptionMiddleware
>', 'django.middleware.common.CommonMiddleware',
> 'django.middleware.transaction.TransactionMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.middleware.doc.XViewMiddleware',
> ]

I found the documentation quite confusing on this point too, and I ended up 
googling for the middleware name to find other examples.  

I think the cache middleware should be around the whole set of middleware 
classes.  Here's what I've gone with:

MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'MySite.dbtemplates.middleware.FlatpageFallbackMiddleware',
'MySite.dbtemplates.middleware.RedirectFallbackMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
)

If I'm wrong, someone please correct me!

Tim.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



TransactionMiddleware and SessionMiddleware

2008-12-10 Thread Thomas Guettler

Hi,

I follow: http://docs.djangoproject.com/en/dev/topics/db/transactions/
{{{
The order is quite important. The transaction middleware applies not
only to view functions, but also for all middleware modules that come
after it. So if you use the session middleware after the transaction
middleware, session creation will be part of the transaction.
}}}

# settings.py
MIDDLEWARE_CLASSES = [

'djangotools.middleware.HandleExceptionMiddleware.HandleExceptionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
]

But the result is not what is excepted if there is an exception:
 1. All DB changes are rolled back by TransactionMiddleware 
(proccess_exception())
 2. Debug-Response is returned. All middleware methods are called:
   SessionMiddleware.process_response() --> commit_unless_managed() --> session 
gets
   saved to DB, since the connection is no longer managed.

Is this a bug or am I missing something?

I use django 1.0.2


  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---