Back to index

plone3  3.1.7
login.py
Go to the documentation of this file.
00001 from zope.interface import implements
00002 from zope.component import getMultiAdapter
00003 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
00004 from plone.portlets.interfaces import IPortletDataProvider
00005 from plone.app.portlets.portlets import base
00006 from Products.CMFPlone import PloneMessageFactory as _
00007 
00008 
00009 class ILoginPortlet(IPortletDataProvider):
00010     """A portlet which can render an OpenID login form.
00011     """
00012 
00013 
00014 class Assignment(base.Assignment):
00015     implements(ILoginPortlet)
00016 
00017     title = _(u'OpenID login')
00018 
00019 
00020 class Renderer(base.Renderer):
00021 
00022     def __init__(self, context, request, view, manager, data):
00023         base.Renderer.__init__(self, context, request, view, manager, data)
00024 
00025         self.portal_state = getMultiAdapter((context, request), name=u'plone_portal_state')
00026         self.pas_info = getMultiAdapter((context, request), name=u'pas_info')
00027 
00028 
00029     def show(self):
00030         if not self.portal_state.anonymous():
00031             return False
00032         if not self.pas_info.hasOpenIDdExtractor():
00033             return False
00034         page = self.request.get('URL', '').split('/')[-1]
00035         return page not in ('login_form', 'join_form')
00036 
00037 
00038     def login_form(self):
00039         return '%s/login_form' % self.portal_state.portal_url()
00040 
00041 
00042     render = ViewPageTemplateFile('login.pt')
00043 
00044 
00045 class AddForm(base.NullAddForm):
00046 
00047     def create(self):
00048         return Assignment()