[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/ - return actions for *all* type infos, using a default URL expression

Yvo Schubbe y.2008 at wcm-solutions.de
Sat Sep 20 08:03:24 EDT 2008


Log message for revision 91286:
  - return actions for *all* type infos, using a default URL expression

Changed:
  U   Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
  U   Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
  U   Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py

-=-
Modified: Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt	2008-09-20 11:56:23 UTC (rev 91285)
+++ Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt	2008-09-20 12:03:23 UTC (rev 91286)
@@ -32,8 +32,7 @@
 
 - TypeInformation and TypesTool: Added support for add view actions.
   Type infos now have a new 'add_view_expr' property and implement IAction.
-  'listActions' of the types tool includes type infos as 'add' actions if
-  an add view URL is specified.
+  'listActions' of the types tool includes type infos as 'add' actions.
 
 - interfaces: Fixed some docstrings.
   There is no IActionInformation. ActionInformation is an old action class

Modified: Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/TypesTool.py	2008-09-20 11:56:23 UTC (rev 91285)
+++ Products.CMFCore/trunk/Products/CMFCore/TypesTool.py	2008-09-20 12:03:23 UTC (rev 91286)
@@ -16,6 +16,7 @@
 """
 
 import logging
+from urllib import quote
 from warnings import warn
 
 import Products
@@ -329,7 +330,7 @@
     def getInfoData(self):
         """ Get the data needed to create an ActionInfo.
         """
-        lazy_keys = ['available', 'allowed']
+        lazy_keys = ['url', 'available', 'allowed']
         lazy_map = {}
 
         lazy_map['id'] = self.getId()
@@ -338,9 +339,9 @@
         lazy_map['description'] = self.Description()
         if self.add_view_expr:
             lazy_map['url'] = self.add_view_expr_object
-            lazy_keys.append('url')
         else:
-            lazy_map['url'] = ''
+            lazy_map['url'] = Expression('string:${folder_url}/+%s'
+                                         % quote(self.getId()))
         if self.content_icon:
             lazy_map['icon'] = Expression('string:${portal_url}/%s'
                                           % self.content_icon)
@@ -786,7 +787,7 @@
                 actions.extend( type_info.listActions(info, object) )
 
         add_actions = [ ti for ti in self.objectValues()
-                        if IAction.providedBy(ti) and ti.add_view_expr ]
+                        if IAction.providedBy(ti) ]
         actions.extend(add_actions)
 
         return actions

Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py	2008-09-20 11:56:23 UTC (rev 91285)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py	2008-09-20 12:03:23 UTC (rev 91286)
@@ -320,13 +320,15 @@
         self.assertEqual(info_data[0]['category'], 'folder/add')
         self.assertEqual(info_data[0]['title'], ti_data['title'])
         self.assertEqual(info_data[0]['description'], ti_data['description'])
-        self.assertEqual(info_data[0]['url'], '')
+        self.assertEqual(info_data[0]['url'].text,
+                         'string:${folder_url}/+foo')
         self.assertEqual(info_data[0]['icon'], '')
         self.assertEqual(info_data[0]['visible'], True)
         self.assertEqual(info_data[0]['available'], ti._checkAvailable)
         self.assertEqual(info_data[0]['allowed'], ti._checkAllowed)
 
-        self.assertEqual(set(info_data[1]), set(['available', 'allowed']))
+        self.assertEqual(set(info_data[1]),
+                         set(['url', 'available', 'allowed']))
 
     def _checkContentTI(self, ti):
         wanted_aliases = { 'view': 'dummy_view', '(Default)': 'dummy_view' }



More information about the Checkins mailing list