src/pyams_security/plugin/__init__.py
changeset 0 f04e1d0a0723
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_security/plugin/__init__.py	Thu Feb 19 10:53:29 2015 +0100
@@ -0,0 +1,41 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+# import standard library
+
+# import interfaces
+
+# import packages
+
+
+class PluginSelector(object):
+    """Plug-in based event selector
+
+    This selector can be used by subscriber to filter authentication
+    events based on the name of the plug-in which fired the event.
+    """
+
+    def __init__(self, name, config):
+        self.plugin_name = name
+
+    def text(self):
+        return 'plugin_selector = %s' % self.plugin_name
+
+    phash = text
+
+    def __call__(self, event):
+        if event.plugin == self.plugin_name:
+            return True
+        return False