Added "NullAdapter" to be able to remove a default adapter for a given context
authorThierry Florac <thierry.florac@onf.fr>
Fri, 10 Nov 2017 13:50:06 +0100
changeset 117 c43465fd39a8
parent 116 fc4d1690cbee
child 118 de78bbbc9f50
Added "NullAdapter" to be able to remove a default adapter for a given context
src/pyams_utils/adapter.py
--- a/src/pyams_utils/adapter.py	Fri Oct 13 10:00:45 2017 +0200
+++ b/src/pyams_utils/adapter.py	Fri Nov 10 13:50:06 2017 +0100
@@ -57,6 +57,16 @@
         self.view = view
 
 
+class NullAdapter(object):
+    """An adapter which always return None!
+
+    Can be useful to override a default adapter...
+    """
+
+    def __new__(cls, *arsg, **kwargs):
+        return None
+
+
 class adapter_config(object):
     """Function or class decorator to declare an adapter