Package madrona :: Package openid
[hide private]

Source Code for Package madrona.openid

 1  # -*- coding: utf-8 -*- 
 2  # Copyright 2007, 2008,2009 by Benoît Chesneau <benoitc@e-engura.org> 
 3  #  
 4  # Licensed under the Apache License, Version 2.0 (the "License"); 
 5  # you may not use this file except in compliance with the License. 
 6  # You may obtain a copy of the License at 
 7  # 
 8  #     http://www.apache.org/licenses/LICENSE-2.0 
 9  # 
10  # Unless required by applicable law or agreed to in writing, software 
11  # distributed under the License is distributed on an "AS IS" BASIS, 
12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
13  # See the License for the specific language governing permissions and 
14  # limitations under the License. 
15  # 
16   
17  """ 
18  Django authentification application to *with openid using django auth contrib/. 
19   
20  This application allow a user to connect to you website with : 
21   * legacy account : username/password 
22   * openid url 
23  """ 
24   
25  from django.conf import settings 
26  from django.core.exceptions import ImproperlyConfigured 
27   
28  try: 
29      from django.utils.importlib import import_module 
30  except ImportError: 
31      # version < 1.1 
32      from madrona.openid.utils.importlib import import_module 
33   
34  __version__ = "1.0.1" 
35   
36  # get openidstore to use. 
37  if not hasattr(settings, 'OPENID_STORE') or not settings.OPENID_STORE: 
38      settings.OPENID_STORE = 'madrona.openid.openid_store.DjangoOpenIDStore' 
39   
40 -def load_store(path):
41 i = path.rfind('.') 42 module, attr = path[:i], path[i + 1:] 43 try: 44 mod = import_module(module) 45 except ImportError, e: 46 raise ImproperlyConfigured('Error importing openid store %s: "%s"' % (module, e)) 47 except ValueError, e: 48 raise ImproperlyConfigured('Error importing openid store. Is OPENID_STORE ' 49 'a correctly defined list or tuple?') 50 try: 51 cls = getattr(mod, attr) 52 except AttributeError: 53 raise ImproperlyConfigured('Module "%s" does not define a "%s" ' 54 'openid store' % (module, attr)) 55 return cls
56 57 DjangoOpenIDStore = load_store(settings.OPENID_STORE) 58