Package madrona :: Package openid :: Module context_processors
[hide private]

Source Code for Module madrona.openid.context_processors

 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 -def authopenid(request):
19 """ 20 Returns context variables required by apps that use django-authopenid. 21 """ 22 if hasattr(request, 'openid'): 23 openid = request.openid 24 else: 25 openid = None 26 27 if hasattr(request, 'openids'): 28 openids = request.openids 29 else: 30 openids = [] 31 32 if hasattr(request, 'associated_openids'): 33 associated_openids = request.associated_openids 34 else: 35 associated_openids = [] 36 37 return { 38 "openid": openid, 39 "openids": openids, 40 "associated_openids": associated_openids, 41 "signin_with_openid": (openid is not None), 42 "has_openids": (len(associated_openids) > 0) 43 }
44