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

Jens Vagelpohl jens at dataflake.org
Sun Sep 25 09:02:39 EDT 2005


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

Changed:
  U   CMF/branches/1.5/CHANGES.txt
  U   CMF/branches/1.5/CMFCore/ActionProviderBase.py
  U   CMF/branches/1.5/CMFCore/DynamicType.py
  U   CMF/branches/1.5/CMFCore/tests/test_ActionProviderBase.py
  U   CMF/branches/1.5/CMFCore/tests/test_DynamicType.py

-=-
Modified: CMF/branches/1.5/CHANGES.txt
===================================================================
--- CMF/branches/1.5/CHANGES.txt	2005-09-25 11:37:06 UTC (rev 38611)
+++ CMF/branches/1.5/CHANGES.txt	2005-09-25 13:02:39 UTC (rev 38612)
@@ -2,6 +2,9 @@
 
   Bug Fixes
 
+    - CMFCore.DynamicType/ActionProviderBase: If an action cannot be looked
+      up, provide a more helpful debugging message for the error log.
+
     - CMFCore.MemberDataTool: Fixed the pruneMemberData functionality in the
       ZMI: Now it is enough to press the button once.
 

Modified: CMF/branches/1.5/CMFCore/ActionProviderBase.py
===================================================================
--- CMF/branches/1.5/CMFCore/ActionProviderBase.py	2005-09-25 11:37:06 UTC (rev 38611)
+++ CMF/branches/1.5/CMFCore/ActionProviderBase.py	2005-09-25 13:02:39 UTC (rev 38612)
@@ -121,7 +121,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/branches/1.5/CMFCore/DynamicType.py
===================================================================
--- CMF/branches/1.5/CMFCore/DynamicType.py	2005-09-25 11:37:06 UTC (rev 38611)
+++ CMF/branches/1.5/CMFCore/DynamicType.py	2005-09-25 13:02:39 UTC (rev 38612)
@@ -75,7 +75,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/branches/1.5/CMFCore/tests/test_ActionProviderBase.py
===================================================================
--- CMF/branches/1.5/CMFCore/tests/test_ActionProviderBase.py	2005-09-25 11:37:06 UTC (rev 38611)
+++ CMF/branches/1.5/CMFCore/tests/test_ActionProviderBase.py	2005-09-25 13:02:39 UTC (rev 38612)
@@ -281,7 +281,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/branches/1.5/CMFCore/tests/test_DynamicType.py
===================================================================
--- CMF/branches/1.5/CMFCore/tests/test_DynamicType.py	2005-09-25 11:37:06 UTC (rev 38611)
+++ CMF/branches/1.5/CMFCore/tests/test_DynamicType.py	2005-09-25 13:02:39 UTC (rev 38612)
@@ -108,7 +108,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