Don't mask server exception with session save exception
|Reported by:||Owned by:||Adrian Holovaty|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Now session is saved even when the server callback method throws an exception. When callback exception is caused by database, sometimes save of session in SessionMiddleware fails and a new exception is thrown. This new exception is presented instead of technical_500_response.
This new stacktrace gives no information of what is the real cause of the exception, the resulting output may end with something that do not give to much information, like that for postgres:
File "C:\Programs\Python\Lib\site-packages\Django-0.95.1-py2.5.egg\django\db\backends\postgresql_psycopg2\base.py", line 46, in cursor cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) ProgrammingError: current transaction is aborted, commands ignored until end of transaction block
Question which can be asked is: Should the session state be saved when an exception is thrown from the callback method? In my opinion it shouldn't be, because it means that something unexpected happen.
I will prepare a patch that will save session only if there was no uncaught exception if it is acceptable solution.
Change History (11)
comment:4 Changed 5 years ago by
|Component:||Core (Other) → contrib.sessions|
|Status:||closed → reopened|
|Version:||SVN → 1.3-beta|