[Checkins] SVN: Products.CMFCore/trunk/Products/CMFCore/ Added `icon_expr` as a new property to type information. This allows you to specify the `content_icon` as an expression and store it. This avoids creating the expression on the fly at rendering time.

Hanno Schlichting plone at hannosch.info
Sat Dec 13 06:13:37 EST 2008


Log message for revision 94014:
  Added `icon_expr` as a new property to type information. This allows you to specify the `content_icon` as an expression and store it. This avoids creating the expression on the fly at rendering time.
  

Changed:
  U   Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt
  U   Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
  U   Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.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-12-13 07:39:03 UTC (rev 94013)
+++ Products.CMFCore/trunk/Products/CMFCore/CHANGES.txt	2008-12-13 11:13:37 UTC (rev 94014)
@@ -4,6 +4,10 @@
 2.2.0 (unreleased)
 ------------------
 
+- Added `icon_expr` as a new property to type information. This allows you
+  to specify the `content_icon` as an expression and store it. This avoids
+  creating the expression on the fly at rendering time.
+
 - Removed superGetAttr fallback from SkinnableObjectManager. None of its base
   classes have a `__getattr__` method anymore.
 

Modified: Products.CMFCore/trunk/Products/CMFCore/TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/TypesTool.py	2008-12-13 07:39:03 UTC (rev 94013)
+++ Products.CMFCore/trunk/Products/CMFCore/TypesTool.py	2008-12-13 11:13:37 UTC (rev 94014)
@@ -90,6 +90,8 @@
          'label':'I18n Domain'},
         {'id':'content_icon', 'type': 'string', 'mode':'w',
          'label':'Icon'},
+        {'id': 'icon_expr', 'type': 'string', 'mode': 'w',
+         'label': 'Icon (Expression)'},
         {'id':'content_meta_type', 'type': 'string', 'mode':'w',
          'label':'Product meta type'},
         )
@@ -119,6 +121,7 @@
     i18n_domain = ''
     content_meta_type = ''
     content_icon = ''
+    icon_expr = ''
     add_view_expr = ''
     immediate_view = ''
     filter_content_types = True
@@ -342,7 +345,10 @@
             lazy_keys.append('url')
         else:
             lazy_map['url'] = ''
-        if self.content_icon:
+        if self.icon_expr:
+            lazy_map['icon'] = self.icon_expr_object
+            lazy_keys.append('icon')
+        elif self.content_icon:
             lazy_map['icon'] = Expression('string:${portal_url}/%s'
                                           % self.content_icon)
             lazy_keys.append('icon')

Modified: Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py	2008-12-13 07:39:03 UTC (rev 94013)
+++ Products.CMFCore/trunk/Products/CMFCore/exportimport/tests/test_typeinfo.py	2008-12-13 11:13:37 UTC (rev 94014)
@@ -40,6 +40,7 @@
  <property name="title"></property>
  <property name="description"></property>
  <property name="content_icon"></property>
+ <property name="icon_expr"></property>
  <property name="content_meta_type"></property>
  <property name="product"></property>
  <property name="factory"></property>
@@ -72,6 +73,7 @@
     'i18n_domain':           'foo_domain',
     'content_meta_type':     'Foo Thing',
     'content_icon':          'foo.png',
+    'icon_expr':             'string:${portal_url}/foo.png',
     'product':               'CMFSetup',
     'factory':               'addFoo',
     'add_view_expr':         'string:${folder_url}/foo_add_view',
@@ -108,6 +110,7 @@
     'description':           'Bar things',
     'content_meta_type':     'Bar Thing',
     'content_icon':          'bar.png',
+    'icon_expr':             'string:${portal_url}/bar.png',
     'constructor_path':      'make_bar',
     'permission':            'Add portal content',
     'add_view_expr':         'string:${folder_url}/bar_add_view',
@@ -188,6 +191,7 @@
  <property name="title" i18n:translate="">Foo</property>
  <property name="description" i18n:translate="">Foo things</property>
  <property name="content_icon">foo.png</property>
+ <property name="icon_expr">string:${portal_url}/foo.png</property>
  <property name="content_meta_type">Foo Thing</property>
  <property name="product">CMFSetup</property>
  <property name="factory">addFoo</property>
@@ -224,6 +228,7 @@
  <property name="title">Bar</property>
  <property name="description">Bar things</property>
  <property name="content_icon">bar.png</property>
+ <property name="icon_expr">string:${portal_url}/bar.png</property>
  <property name="content_meta_type">Bar Thing</property>
  <property name="permission">Add portal content</property>
  <property name="constructor_path">make_bar</property>

Modified: Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py
===================================================================
--- Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py	2008-12-13 07:39:03 UTC (rev 94013)
+++ Products.CMFCore/trunk/Products/CMFCore/tests/test_TypesTool.py	2008-12-13 11:13:37 UTC (rev 94014)
@@ -284,6 +284,7 @@
                    'content_icon': 'foo_icon.gif',
                    'content_meta_type': 'Foo Content',
                    'factory' : 'cmf.foo',
+                   'icon_expr' : 'string:${portal_url}/foo_icon_expr.gif',
                    'add_view_expr': 'string:${folder_url}/foo_add_view'}
         ti = self._makeInstance(**ti_data)
         info_data = ti.getInfoData()
@@ -297,7 +298,7 @@
         self.assertEqual(info_data[0]['url'].text,
                          'string:${folder_url}/foo_add_view')
         self.assertEqual(info_data[0]['icon'].text,
-                         'string:${portal_url}/foo_icon.gif')
+                         'string:${portal_url}/foo_icon_expr.gif')
         self.assertEqual(info_data[0]['visible'], True)
         self.assertEqual(info_data[0]['available'], ti._checkAvailable)
         self.assertEqual(info_data[0]['allowed'], ti._checkAllowed)



More information about the Checkins mailing list