src/pyams_security/plugin/__init__.py
changeset 0 f04e1d0a0723
equal deleted inserted replaced
-1:000000000000 0:f04e1d0a0723
       
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 
       
    20 # import packages
       
    21 
       
    22 
       
    23 class PluginSelector(object):
       
    24     """Plug-in based event selector
       
    25 
       
    26     This selector can be used by subscriber to filter authentication
       
    27     events based on the name of the plug-in which fired the event.
       
    28     """
       
    29 
       
    30     def __init__(self, name, config):
       
    31         self.plugin_name = name
       
    32 
       
    33     def text(self):
       
    34         return 'plugin_selector = %s' % self.plugin_name
       
    35 
       
    36     phash = text
       
    37 
       
    38     def __call__(self, event):
       
    39         if event.plugin == self.plugin_name:
       
    40             return True
       
    41         return False