[CMF-checkins] SVN: CMF/trunk/CMFCore/ - CMFCore.DynamicType/ActionProviderBase: If an action cannot be looked

Jens Vagelpohl jens at dataflake.org
Sun Sep 25 09:03:16 EDT 2005


Log message for revision 38613:
  - CMFCore.DynamicType/ActionProviderBase: If an action cannot be looked
    up, provide a more helpful debugging message for the error log.
  

Changed:
  U   CMF/trunk/CMFCore/ActionProviderBase.py
  U   CMF/trunk/CMFCore/DynamicType.py
  U   CMF/trunk/CMFCore/tests/test_ActionProviderBase.py
  U   CMF/trunk/CMFCore/tests/test_DynamicType.py

-=-
Modified: CMF/trunk/CMFCore/ActionProviderBase.py
===================================================================
--- CMF/trunk/CMFCore/ActionProviderBase.py	2005-09-25 13:02:39 UTC (rev 38612)
+++ CMF/trunk/CMFCore/ActionProviderBase.py	2005-09-25 13:03:16 UTC (rev 38613)
@@ -124,7 +124,13 @@
                                             check_permissions=False,
                                             check_condition=check_condition)
         if not action_infos:
-            raise ValueError('No Action meets the given specification.')
+            if object is None:
+                provider = self
+            else:
+                provider = object
+            msg = 'Action "%s" not available for %s' % (
+                        action_chain, '/'.join(provider.getPhysicalPath()))
+            raise ValueError(msg)
         for ai in action_infos:
             if ai['allowed']:
                 return ai

Modified: CMF/trunk/CMFCore/DynamicType.py
===================================================================
--- CMF/trunk/CMFCore/DynamicType.py	2005-09-25 13:02:39 UTC (rev 38612)
+++ CMF/trunk/CMFCore/DynamicType.py	2005-09-25 13:03:16 UTC (rev 38613)
@@ -79,7 +79,9 @@
             return ti.getActionInfo(action_chain, self, check_visibility,
                                     check_condition)
         else:
-            raise ValueError('No Action meets the given specification.')
+            msg = 'Action "%s" not available for %s' % (
+                        action_chain, '/'.join(self.getPhysicalPath()))
+            raise ValueError(msg) 
 
     # Support for dynamic icons
 

Modified: CMF/trunk/CMFCore/tests/test_ActionProviderBase.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_ActionProviderBase.py	2005-09-25 13:02:39 UTC (rev 38612)
+++ CMF/trunk/CMFCore/tests/test_ActionProviderBase.py	2005-09-25 13:03:16 UTC (rev 38613)
@@ -274,7 +274,17 @@
                            apb.getActionInfo,
                            'object/an_id', check_visibility=1 )
 
+        # The following is nasty, but I want to make sure the ValueError
+        # carries some useful information
+        INVALID_ID = 'invalid_id'
+        try:
+            rval = apb.getActionInfo('object/%s' % INVALID_ID)
+        except ValueError, e:
+            message = e.args[0]
+            detail = '"%s" does not offer action "%s"' % (message, INVALID_ID)
+            self.failUnless(message.find(INVALID_ID) != -1, detail)
 
+
 def test_suite():
     return TestSuite((
         makeSuite(ActionProviderBaseTests),

Modified: CMF/trunk/CMFCore/tests/test_DynamicType.py
===================================================================
--- CMF/trunk/CMFCore/tests/test_DynamicType.py	2005-09-25 13:02:39 UTC (rev 38612)
+++ CMF/trunk/CMFCore/tests/test_DynamicType.py	2005-09-25 13:03:16 UTC (rev 38613)
@@ -101,7 +101,17 @@
         foo = self.site.foo
         self.assertEqual( foo.getActionInfo('object/view')['id'], 'view' )
 
+        # The following is nasty, but I want to make sure the ValueError
+        # carries some useful information
+        INVALID_ID = 'invalid_id'
+        try:
+            rval = foo.getActionInfo('object/%s' % INVALID_ID)
+        except ValueError, e:
+            message = e.args[0]
+            detail = '"%s" does not offer action "%s"' % (message, INVALID_ID)
+            self.failUnless(message.find(INVALID_ID) != -1, detail)
 
+
 def test_suite():
     return TestSuite((
         makeSuite(DynamicTypeTests),



More information about the CMF-checkins mailing list