comparison MoinMoin/userprefs/oid.py @ 6103:500f68d3e2fd

remove our own usage of python_compatibility module
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 06 Sep 2016 01:00:25 +0200
parents f7f9d35f9d23
children
comparison
equal deleted inserted replaced
6102:df21062e294d 6103:500f68d3e2fd
3 MoinMoin - OpenID preferences 3 MoinMoin - OpenID preferences
4 4
5 @copyright: 2007 MoinMoin:JohannesBerg 5 @copyright: 2007 MoinMoin:JohannesBerg
6 @license: GNU GPL, see COPYING for details. 6 @license: GNU GPL, see COPYING for details.
7 """ 7 """
8 import hashlib
8 9
9 from MoinMoin import wikiutil, user 10 from MoinMoin import wikiutil, user
10 from MoinMoin.widget import html 11 from MoinMoin.widget import html
11 from MoinMoin.userprefs import UserPrefBase 12 from MoinMoin.userprefs import UserPrefBase
12 from MoinMoin.support.python_compatibility import hash_new
13 13
14 try: 14 try:
15 from MoinMoin.auth.openidrp import OpenIDAuth 15 from MoinMoin.auth.openidrp import OpenIDAuth
16 from MoinMoin.util.moinoid import MoinOpenIDStore 16 from MoinMoin.util.moinoid import MoinOpenIDStore
17 from openid.consumer import consumer 17 from openid.consumer import consumer
44 _ = self.request.getText 44 _ = self.request.getText
45 if not hasattr(self.request.user, 'openids'): 45 if not hasattr(self.request.user, 'openids'):
46 return 46 return
47 openids = self.request.user.openids[:] 47 openids = self.request.user.openids[:]
48 for oid in self.request.user.openids: 48 for oid in self.request.user.openids:
49 name = "rm-%s" % hash_new('sha1', oid).hexdigest() 49 name = "rm-%s" % hashlib.new('sha1', oid).hexdigest()
50 if name in self.request.form: 50 if name in self.request.form:
51 openids.remove(oid) 51 openids.remove(oid)
52 if not openids and len(self.request.cfg.auth) == 1: 52 if not openids and len(self.request.cfg.auth) == 1:
53 return 'error', _("Cannot remove all OpenIDs.") 53 return 'error', _("Cannot remove all OpenIDs.")
54 self.request.user.openids = openids 54 self.request.user.openids = openids
170 170
171 def _oidlist(self): 171 def _oidlist(self):
172 _ = self.request.getText 172 _ = self.request.getText
173 form = self._make_form() 173 form = self._make_form()
174 for oid in self.request.user.openids: 174 for oid in self.request.user.openids:
175 name = "rm-%s" % hash_new('sha1', oid).hexdigest() 175 name = "rm-%s" % hashlib.new('sha1', oid).hexdigest()
176 form.append(html.INPUT(type="checkbox", name=name, id=name)) 176 form.append(html.INPUT(type="checkbox", name=name, id=name))
177 form.append(html.LABEL(for_=name).append(html.Text(oid))) 177 form.append(html.LABEL(for_=name).append(html.Text(oid)))
178 form.append(html.BR()) 178 form.append(html.BR())
179 self._make_row(_("Current OpenIDs"), [form], valign='top') 179 self._make_row(_("Current OpenIDs"), [form], valign='top')
180 label = _("Remove selected") 180 label = _("Remove selected")