Log message for revision 86456:
  Launchpad #142350: Display description for properties as row title, if 
present.
  
  

Changed:
  U   Zope/branches/2.11/doc/CHANGES.txt
  U   Zope/branches/2.11/lib/python/OFS/PropertyManager.py
  U   Zope/branches/2.11/lib/python/OFS/dtml/properties.dtml
  U   Zope/branches/2.11/lib/python/OFS/tests/testProperties.py

-=-
Modified: Zope/branches/2.11/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.11/doc/CHANGES.txt  2008-05-05 15:22:12 UTC (rev 86455)
+++ Zope/branches/2.11/doc/CHANGES.txt  2008-05-05 15:25:30 UTC (rev 86456)
@@ -8,6 +8,9 @@
 
     Bugs Fixed
 
+      - Launchpad #142350: Display description for properties as row title,
+        if present.
+
       - Launchpad #200007: DateTime(anotherDateTime) now preserves the
         timezone.
 

Modified: Zope/branches/2.11/lib/python/OFS/PropertyManager.py
===================================================================
--- Zope/branches/2.11/lib/python/OFS/PropertyManager.py        2008-05-05 
15:22:12 UTC (rev 86455)
+++ Zope/branches/2.11/lib/python/OFS/PropertyManager.py        2008-05-05 
15:25:30 UTC (rev 86456)
@@ -258,6 +258,16 @@
                 return p.get('label', id)
         return id
 
+    security.declareProtected(access_contents_information,
+                              'propertyDescription')
+    def propertyDescription(self, id):
+        """Return a description for the given property id
+        """
+        for p in self._properties:
+            if p['id'] == id:
+                return p.get('description', '')
+        return id
+
     security.declareProtected(access_contents_information, 'propdict')
     def propdict(self):
         dict={}

Modified: Zope/branches/2.11/lib/python/OFS/dtml/properties.dtml
===================================================================
--- Zope/branches/2.11/lib/python/OFS/dtml/properties.dtml      2008-05-05 
15:22:12 UTC (rev 86455)
+++ Zope/branches/2.11/lib/python/OFS/dtml/properties.dtml      2008-05-05 
15:25:30 UTC (rev 86456)
@@ -61,8 +61,9 @@
 </tr>
 
 <dtml-in propertyMap mapping>
-<dtml-let type="not _.has_key('type') and 'string' or type">
-<tr>
+<dtml-let type="not _.has_key('type') and 'string' or type"
+          pdesc="propertyDescription(id)">
+<tr title="&dtml-pdesc;">
   <td align="left" valign="top" width="16">
   <dtml-if "'d' in _['sequence-item'].get('mode', 'awd')">
   <input type="checkbox" name="_ids:<dtml-var 
"REQUEST['management_page_charset_tag']">string:list" value="&dtml-id;"

Modified: Zope/branches/2.11/lib/python/OFS/tests/testProperties.py
===================================================================
--- Zope/branches/2.11/lib/python/OFS/tests/testProperties.py   2008-05-05 
15:22:12 UTC (rev 86455)
+++ Zope/branches/2.11/lib/python/OFS/tests/testProperties.py   2008-05-05 
15:25:30 UTC (rev 86456)
@@ -21,10 +21,12 @@
 class TestPropertyManager(unittest.TestCase):
     """Property management tests."""
 
-    def _makeOne(self, *args, **kw):
+    def _getTargetClass(self):
         from OFS.PropertyManager import PropertyManager
+        return PropertyManager
 
-        return PropertyManager(*args, **kw)
+    def _makeOne(self, *args, **kw):
+        return self._getTargetClass()(*args, **kw)
 
     def test_z3interfaces(self):
         from OFS.interfaces import IPropertyManager
@@ -52,7 +54,41 @@
         self.failUnless(type(inst.getProperty('prop2')) == type(()))
         self.failUnless(type(inst.prop2) == type(()))
 
+    def test_propertyLabel_no_label_falls_back_to_id(self):
+        class NoLabel(self._getTargetClass()):
+            _properties = (
+                {'id': 'no_label', 'type': 'string'},
+            )
+        inst = NoLabel()
+        self.assertEqual(inst.propertyLabel('no_label'), 'no_label')
 
+    def test_propertyLabel_with_label(self):
+        class WithLabel(self._getTargetClass()):
+            _properties = (
+                {'id': 'with_label', 'type': 'string', 'label': 'With Label'},
+            )
+        inst = WithLabel()
+        self.assertEqual(inst.propertyLabel('with_label'), 'With Label')
+
+    def test_propertyDescription_no_description_falls_back_to_id(self):
+        class NoDescription(self._getTargetClass()):
+            _properties = (
+                {'id': 'no_description', 'type': 'string'},
+            )
+        inst = NoDescription()
+        self.assertEqual(inst.propertyDescription('no_description'), '')
+
+    def test_propertyDescription_with_description(self):
+        class WithDescription(self._getTargetClass()):
+            _properties = (
+                {'id': 'with_description', 'type': 'string',
+                 'description': 'With Description'},
+            )
+        inst = WithDescription()
+        self.assertEqual(inst.propertyDescription('with_description'),
+                         'With Description')
+
+
 class TestPropertySheet(unittest.TestCase):
     """Property management tests."""
 

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to