Back to index

plone3  3.1.7
info.py
Go to the documentation of this file.
00001 from zope.interface import implements
00002 from plone.memoize.instance import memoize
00003 
00004 from Acquisition import aq_inner
00005 from Products.PlonePAS.interfaces.browser import IPASInfoView
00006 from Products.PluggableAuthService.interfaces.plugins \
00007                 import IExtractionPlugin, ILoginPasswordExtractionPlugin
00008 from Products.CMFCore.utils import getToolByName
00009 from Products.Five import BrowserView
00010 
00011 
00012 class PASInfoView(BrowserView):
00013     implements(IPASInfoView)
00014 
00015     def checkExtractorForInterface(self, interface):
00016         acl = getToolByName(aq_inner(self.context), "acl_users")
00017         plugins=acl.plugins.listPlugins(IExtractionPlugin)
00018 
00019         for plugin in plugins:
00020             if interface.providedBy(plugin[1]):
00021                 return True
00022 
00023         return False
00024 
00025     @memoize
00026     def hasLoginPasswordExtractor(self):
00027         return self.checkExtractorForInterface(ILoginPasswordExtractionPlugin)
00028 
00029 
00030     @memoize
00031     def hasOpenIDdExtractor(self):
00032         try:
00033             from plone.openid.interfaces import IOpenIdExtractionPlugin
00034         except ImportError:
00035             return False
00036 
00037         return self.checkExtractorForInterface(IOpenIdExtractionPlugin)