[Erp5-report] r44252 jerome - /erp5/trunk/products/ERP5Type/Base.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Mar 14 17:04:14 CET 2011


Author: jerome
Date: Mon Mar 14 17:04:14 2011
New Revision: 44252

URL: http://svn.erp5.org?rev=44252&view=rev
Log:
instead of comparing interfaces by name, use Interface.implementedBy. The
later works properly with interfaces inheritance.

Modified:
    erp5/trunk/products/ERP5Type/Base.py

Modified: erp5/trunk/products/ERP5Type/Base.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/Base.py?rev=44252&r1=44251&r2=44252&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/Base.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/Base.py [utf8] Mon Mar 14 17:04:14 2011
@@ -719,11 +719,12 @@ class Base( CopyContainer,
   security.declarePublic('provides')
   def provides(cls, interface_name):
     """
-    Check if the current class provides a particular interface
+    Check if the current class provides a particular interface from ERP5Type's
+    interfaces registry
     """
-    for interface in implementedBy(cls):
-      if interface.getName() == interface_name:
-        return True
+    interface = getattr(interfaces, interface_name, None)
+    if interface is not None:
+      return interface.implementedBy(cls)
     return False
   provides = classmethod(CachingMethod(provides, 'Base.provides',
                                        cache_factory='erp5_ui_long'))



More information about the Erp5-report mailing list