diff options
| author | Christophe Simonis <chs@openerp.com> | 2012-08-13 17:06:05 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2012-08-13 17:06:05 +0200 |
| commit | 661b4e0786f28e9765344e2457cd392fc2a1f331 (patch) | |
| tree | c41c479a1fb7b3a201f506d755fa0f0eb5af9400 | |
| parent | 26efdb4b9837c24d487532976f5e9ac444588483 (diff) | |
[IMP] auth_signup: use contextmanager to manage the cursor
bzr revid: chs@openerp.com-20120813150605-964tpaedgremjnoa
| -rw-r--r-- | addons/auth_signup/controllers/main.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index b67a391c4c1..0ed2151d12b 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -2,7 +2,7 @@ import logging import werkzeug.urls -import openerp.modules.registry +from openerp.modules.registry import RegistryManager from openerp.addons.web.controllers.main import login_and_redirect import openerp.addons.web.common.http as openerpweb @@ -13,10 +13,9 @@ class OpenIDController(openerpweb.Controller): @openerpweb.httprequest def signup(self, req, dbname, name, login, password): - registry = openerp.modules.registry.RegistryManager.get(dbname) - cr = registry.db.cursor() url = '/' - try: + registry = RegistryManager.get(dbname) + with registry.cursor() as cr: try: Users = registry.get('res.users') credentials = Users.auth_signup(cr, 1, name, login, password) @@ -30,8 +29,6 @@ class OpenIDController(openerpweb.Controller): # signup error _logger.exception('error when signup') url = "/#action=auth_signup&error=UE" # Unexcpected Error - finally: - cr.close() return werkzeug.utils.redirect(url) # vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4: |
