diff options
| author | Christophe Simonis <chs@openerp.com> | 2011-09-30 15:28:58 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2011-09-30 15:28:58 +0200 |
| commit | d028d22992917a3f898db127828ffc9e42af7246 (patch) | |
| tree | 63bd47a75cd6721b424ffbc2869c22339c5b80f2 /addons/auth_openid/utils.py | |
| parent | 8507f7cc4a446da13a83abf5ff711a730bc60e8c (diff) | |
[ADD] auth_openid module
bzr revid: chs@openerp.com-20110930132858-jsxqo21l7pn172av
Diffstat (limited to 'addons/auth_openid/utils.py')
| -rw-r--r-- | addons/auth_openid/utils.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/addons/auth_openid/utils.py b/addons/auth_openid/utils.py new file mode 100644 index 00000000000..2761f3d0e1d --- /dev/null +++ b/addons/auth_openid/utils.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2010-2011 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 +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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/>. +# +############################################################################## +from contextlib import contextmanager +from openerp.modules.registry import RegistryManager + +KEY_LENGTH = 16 + +SREG2AX = { # from http://www.axschema.org/types/#sreg + 'nickname': 'http://axschema.org/namePerson/friendly', + 'email': 'http://axschema.org/contact/email', + 'fullname': 'http://axschema.org/namePerson', + 'dob': 'http://axschema.org/birthDate', + 'gender': 'http://axschema.org/person/gender', + 'postcode': 'http://axschema.org/contact/postalCode/home', + 'country': 'http://axschema.org/contact/country/home', + 'language': 'http://axschema.org/pref/language', + 'timezone': 'http://axschema.org/pref/timezone', +} + + +@contextmanager +def cursor(db): + cr = RegistryManager.get(db).db.cursor() + try: + yield cr + finally: + cr.close() + |
