comparison MoinMoin/userprefs/oid.py @ 2370:6d9970321d79

disable openid preferences if openid libs are not installed
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 12 Jul 2007 11:45:51 +0200
parents 96ec23afac7d
children 0d04c8c82eb6
comparison
equal deleted inserted replaced
2369:ccf996479233 2370:6d9970321d79
7 """ 7 """
8 8
9 from MoinMoin import wikiutil, user 9 from MoinMoin import wikiutil, user
10 from MoinMoin.widget import html 10 from MoinMoin.widget import html
11 from MoinMoin.userprefs import UserPrefBase 11 from MoinMoin.userprefs import UserPrefBase
12 from MoinMoin.auth.openidrp import OpenIDAuth
13 import sha 12 import sha
14 from MoinMoin.util.moinoid import MoinOpenIDStore 13 try:
15 from openid.consumer import consumer 14 from MoinMoin.auth.openidrp import OpenIDAuth
16 from openid.yadis.discover import DiscoveryFailure 15 from MoinMoin.util.moinoid import MoinOpenIDStore
17 from openid.fetchers import HTTPFetchingError 16 from openid.consumer import consumer
17 from openid.yadis.discover import DiscoveryFailure
18 from openid.fetchers import HTTPFetchingError
19 _openid_disabled = False
20 except ImportError:
21 _openid_disabled = True
18 22
19 23
20 class Settings(UserPrefBase): 24 class Settings(UserPrefBase):
21 def __init__(self, request): 25 def __init__(self, request):
22 """ Initialize OpenID settings form. """ 26 """ Initialize OpenID settings form. """
25 self._ = request.getText 29 self._ = request.getText
26 self.cfg = request.cfg 30 self.cfg = request.cfg
27 self.title = self._("OpenID settings") 31 self.title = self._("OpenID settings")
28 32
29 def allowed(self): 33 def allowed(self):
34 if _openid_disabled:
35 return False
30 for authm in self.request.cfg.auth: 36 for authm in self.request.cfg.auth:
31 if isinstance(authm, OpenIDAuth): 37 if isinstance(authm, OpenIDAuth):
32 return UserPrefBase.allowed(self) 38 return UserPrefBase.allowed(self)
33 return False 39 return False
34 40