[rhmessaging-commits] rhmessaging commits: r4257 - in mgmt/newdata: rosemary/python/rosemary and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Sep 7 12:19:01 EDT 2010


Author: eallen
Date: 2010-09-07 12:19:01 -0400 (Tue, 07 Sep 2010)
New Revision: 4257

Modified:
   mgmt/newdata/cumin/python/cumin/objectselector.py
   mgmt/newdata/rosemary/python/rosemary/model.py
Log:
Fixing unreported exception.
Removing a broker links threw an exception when displaying the remove form. This was due to the fact that the ResemaryObject link does not have a name attribute.
The fix was to call the get_formatted_value("name") method on RoseMary object which now handles missing attributes.

Modified: mgmt/newdata/cumin/python/cumin/objectselector.py
===================================================================
--- mgmt/newdata/cumin/python/cumin/objectselector.py	2010-09-07 14:56:35 UTC (rev 4256)
+++ mgmt/newdata/cumin/python/cumin/objectselector.py	2010-09-07 16:19:01 UTC (rev 4257)
@@ -275,7 +275,7 @@
         pass
 
     def get_item_content(self, session, item):
-        return item.name
+        return item.get_formatted_value("name")
 
 class ObjectSelectorTaskForm(FoldingFieldSubmitForm):
     def __init__(self, app, name, task):

Modified: mgmt/newdata/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/newdata/rosemary/python/rosemary/model.py	2010-09-07 14:56:35 UTC (rev 4256)
+++ mgmt/newdata/rosemary/python/rosemary/model.py	2010-09-07 16:19:01 UTC (rev 4257)
@@ -757,13 +757,20 @@
                 return self.get_formatted_value(attr)
 
     def get_formatted_value(self, attr):
-        value = getattr(self, attr, None)
+        value = self.get_value(attr)
         formatter = None
         if attr in self._class._properties_by_name:
             formatter = self._class._properties_by_name[attr].formatter
         #TODO: handle formatters on statistics and headers as well
         return formatter and formatter(value) or value
 
+    def get_value(self, attr):
+        value = getattr(self, attr, None)
+        if not value:
+            # there is no attr, return the value of the 1st property
+            value = getattr(self, self._class._properties[0].name)
+        return value
+
     def __repr__(self):
         name = self.__class__.__name__
         args = (name, self._class, self._id, self._sync_time)



More information about the rhmessaging-commits mailing list