[IMP] auth_openid: use registry.cursor() instead of utils.cursor()
bzr revid: chs@openerp.com-20120813154419-4rwe6d4w6w0irl37
This commit is contained in:
parent
f25ad66a8f
commit
6a33cfa71a
|
@ -172,8 +172,8 @@ class OpenIDController(openerpweb.Controller):
|
|||
|
||||
if info.status == consumer.SUCCESS:
|
||||
dbname = session['dbname']
|
||||
with utils.cursor(dbname) as cr:
|
||||
registry = RegistryManager.get(dbname)
|
||||
registry = RegistryManager.get(dbname)
|
||||
with registry.cursor() as cr:
|
||||
Modules = registry.get('ir.module.module')
|
||||
|
||||
installed = Modules.search_count(cr, 1, ['&', ('name', '=', 'auth_openid'), ('state', '=', 'installed')]) == 1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
|
||||
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -18,6 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp.modules.registry import RegistryManager
|
||||
from openerp.osv import osv, fields
|
||||
import openerp.exceptions
|
||||
import tools
|
||||
|
@ -64,7 +65,7 @@ class res_users(osv.osv):
|
|||
if result:
|
||||
return result
|
||||
else:
|
||||
with utils.cursor(db) as cr:
|
||||
with RegistryManager.get(db).cursor() as cr:
|
||||
cr.execute("""UPDATE res_users
|
||||
SET date=now() AT TIME ZONE 'UTC'
|
||||
WHERE login=%s AND openid_key=%s AND active=%s RETURNING id""",
|
||||
|
@ -73,14 +74,13 @@ class res_users(osv.osv):
|
|||
cr.commit()
|
||||
return res[0] if res else False
|
||||
|
||||
|
||||
def check(self, db, uid, passwd):
|
||||
try:
|
||||
return super(res_users, self).check(db, uid, passwd)
|
||||
except openerp.exceptions.AccessDenied:
|
||||
if not passwd:
|
||||
raise
|
||||
with utils.cursor(db) as cr:
|
||||
with RegistryManager.get(db).cursor() as cr:
|
||||
cr.execute('''SELECT COUNT(1)
|
||||
FROM res_users
|
||||
WHERE id=%s
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
##############################################################################
|
||||
#
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2010-2011 OpenERP s.a. (<http://openerp.com>).
|
||||
# Copyright (C) 2010-2012 OpenERP s.a. (<http://openerp.com>).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
|
@ -15,11 +15,9 @@
|
|||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from contextlib import contextmanager
|
||||
from openerp.modules.registry import RegistryManager
|
||||
|
||||
KEY_LENGTH = 16
|
||||
|
||||
|
@ -35,14 +33,4 @@ SREG2AX = { # from http://www.axschema.org/types/#sreg
|
|||
'timezone': 'http://axschema.org/pref/timezone',
|
||||
}
|
||||
|
||||
|
||||
@contextmanager
|
||||
def cursor(db):
|
||||
cr = RegistryManager.get(db).db.cursor()
|
||||
try:
|
||||
yield cr
|
||||
finally:
|
||||
cr.close()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue