summaryrefslogtreecommitdiff
path: root/addons/auth_openid/utils.py
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2011-10-13 19:03:27 +0200
committerOlivier Dony <odo@openerp.com>2011-10-13 19:03:27 +0200
commit3bffe65b2ca8bc50ece644e7947ad2bbd5c9341a (patch)
treeb307874680dbdce7b2f5109b7b696ea38e679e20 /addons/auth_openid/utils.py
parenta93ca01b5b1365f92e191e3c429ef655e751b455 (diff)
parent8a7c61cb96a541a9aaca51ffe3ee903407b26360 (diff)
[MERGE] sync with latest trunk
bzr revid: odo@openerp.com-20111013170327-9rvfdkbgj01hdgxb
Diffstat (limited to 'addons/auth_openid/utils.py')
-rw-r--r--addons/auth_openid/utils.py46
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()
+