From 5c6087e38ee671ad5a3cf5aaa501d2a46af49872 Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Wed, 21 Sep 2016 14:37:55 +0200 Subject: [PATCH] [FIX] web: dropping a database leads to an unusable cursor Explicitly remove the cursor of the request. Dropping a database is not transactional and if overrides of ir_http's dispatch worked with the database (for example, utm), we are not able to commit the changes at the end of the request. It worked nice before rev 40561b0fb6b8f that changed the use of self.pool by request.env. Note: a cursor is always attached to an environment. Since the call to super possibly broke the cursor (for example by dropping the database), the end of the dispatch operation that try to commit and/or close the cursor could possibly result in the traceback 'unable to close a closed cursor' with request.env. With self.pool, it didn't happen because the code actually called in the utm's dispatch override doesn't use a cr and so there's nothing to close. --- addons/web/controllers/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index 08042763369..ce609a3b3e5 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -652,6 +652,7 @@ class Database(http.Controller): def drop(self, master_pwd, name): try: dispatch_rpc('db','drop', [master_pwd, name]) + request._cr = None # dropping a database leads to an unusable cursor return http.local_redirect('/web/database/manager') except Exception, e: error = "Database deletion error: %s" % e