[rhmessaging-commits] rhmessaging commits: r1125 - in mgmt/cumin/python: wooly and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Oct 19 16:13:07 EDT 2007


Author: justi9
Date: 2007-10-19 16:13:06 -0400 (Fri, 19 Oct 2007)
New Revision: 1125

Modified:
   mgmt/cumin/python/cumin/demo.py
   mgmt/cumin/python/cumin/model.py
   mgmt/cumin/python/cumin/queue.py
   mgmt/cumin/python/cumin/queue.strings
   mgmt/cumin/python/wooly/__init__.py
Log:
Adds an initial statistics tab to the queue view.  Improves the fake
demo stats a little.  Fixes a bug in the way Template was rendering
zeros.



Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py	2007-10-19 19:33:00 UTC (rev 1124)
+++ mgmt/cumin/python/cumin/demo.py	2007-10-19 20:13:06 UTC (rev 1125)
@@ -166,7 +166,11 @@
                         try:
                             for stat in queue.stats:
                                 if stat.type == "int" and random() < 0.33:
-                                    stat.value += 1
+                                    if random() < 0.5:
+                                        stat.value += randint(4, 12)
+                                    else:
+                                        value = stat.value - randint(3, 9)
+                                        stat.value = value > 0 and value or 0
 
                             queue.message_count += 1
 

Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2007-10-19 19:33:00 UTC (rev 1124)
+++ mgmt/cumin/python/cumin/model.py	2007-10-19 20:13:06 UTC (rev 1125)
@@ -273,8 +273,12 @@
         self.name = name
         self.type = type
         self.title = None
-        self.value = None
 
+        if type == "int":
+            self.value = 0
+        else:
+            self.value = None
+
 class Queue(ModelObject):
     def __init__(self, model):
         super(Queue, self).__init__(model, model.queue)

Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py	2007-10-19 19:33:00 UTC (rev 1124)
+++ mgmt/cumin/python/cumin/queue.py	2007-10-19 20:13:06 UTC (rev 1125)
@@ -104,12 +104,8 @@
         self.add_child(self.tabs)
 
         self.tabs.add_tab(QueueBindingSet(app, "bindings"))
-        self.tabs.add_tab(self.QueueLog(app, "log"))
+        self.tabs.add_tab(QueueStatistics(app, "stats"))
 
-    class QueueLog(Widget):
-        def render_title(self, session, queue):
-            return "Log Messages"
-
     def render_title(self, session, queue):
         return "Queue '%s'" % queue.name
 
@@ -343,3 +339,16 @@
 
     def render_cancel_content(self, session, binding):
         return "No, Cancel"
+
+class QueueStatistics(ItemSet):
+    def render_title(self, session, queue):
+        return "Statistics"
+
+    def get_items(self, session, queue):
+        return queue.stats
+
+    def render_item_title(self, session, stat):
+        return stat.title
+
+    def render_item_value(self, session, stat):
+        return stat.value

Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings	2007-10-19 19:33:00 UTC (rev 1124)
+++ mgmt/cumin/python/cumin/queue.strings	2007-10-19 20:13:06 UTC (rev 1125)
@@ -163,3 +163,20 @@
 }())
 </script>
 
+[QueueStatistics.html]
+<table class="mobjects">
+  <tr>
+    <th style="background-color: white;"></th>
+    <th>Current Value</th>
+    <th>Average Value</th>
+  </tr>
+
+  {items}
+</table>
+
+[QueueStatistics.item_html]
+<tr>
+  <th>{item_title}</th>
+  <td>{item_value}</td>
+  <td></td>
+</tr>
\ No newline at end of file

Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py	2007-10-19 19:33:00 UTC (rev 1124)
+++ mgmt/cumin/python/wooly/__init__.py	2007-10-19 20:13:06 UTC (rev 1125)
@@ -676,9 +676,11 @@
             if type(elem) is str:
                 writer.write(elem)
             elif callable(elem):
-                writer.write(str(elem(self.widget, session, object) or ""))
+                result = elem(self.widget, session, object)
+                writer.write(result == None and "" or str(result))
             else:
-                writer.write(str(elem.render(session, object) or ""))
+                result = elem.render(session, object)
+                writer.write(result == None and "" or str(result))
 
 class WidgetCall(object):
     def __init__(self, stack, widget, session, object):




More information about the rhmessaging-commits mailing list