Author: justi9
Date: 2007-12-12 11:33:33 -0500 (Wed, 12 Dec 2007)
New Revision: 1464
Modified:
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/widgets.py
mgmt/notes/justin-todo.txt
Log:
Paginates queue and exchange bindings.
Adds a BindingSet used in common by ExchangeBindingSet and
QueueBindingSet.
Adds a PaginatedItemSet for use in any collection that is to be
paginated.
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/exchange.py 2007-12-12 16:33:33 UTC (rev 1464)
@@ -204,12 +204,17 @@
def render_updated(self, session, exchange):
return fmt_datetime(exchange.recTime)
-class ExchangeBindingSet(ItemSet):
+class ExchangeBindingSet(BindingSet):
def get_title(self, session, exchange):
- return "Queue Bindings %s" % fmt_count(len(exchange.bindings))
+ return "Queue Bindings %s" % \
+ fmt_count(self.get_item_count(session, exchange))
+ def get_item_count(self, session, exchange):
+ return Binding.select(Binding.q.exchangeID == exchange.id).count()
+
def do_get_items(self, session, exchange):
- return sorted_by(exchange.bindings, "id")
+ start, end = self.get_bounds(session)
+ return Binding.select(Binding.q.exchangeID == exchange.id)[start:end]
def render_item_href(self, session, binding):
branch = session.branch()
@@ -219,17 +224,6 @@
def render_item_name(self, session, binding):
return binding.queue.name
- def render_item_binding_key(self, session, binding):
- return binding.bindingKey
-
- def render_item_messages_matched(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return stat.value(binding)
-
- def render_item_messages_matched_rate(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return fmt_rate(stat.rate(binding), "msg", "sec")
-
class ExchangeForm(CuminForm):
def __init__(self, app, name):
super(ExchangeForm, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-12-12 16:33:33 UTC (rev 1464)
@@ -169,6 +169,9 @@
{tabs}
[ExchangeBindingSet.html]
+<div class="rfloat">{page}</div>
+<ul class="radiotabs"> </ul>
+
<table class="ExchangeBindingSet mobjects">
<tr>
<th>Queue</th>
@@ -181,7 +184,7 @@
[ExchangeBindingSet.item_html]
<tr>
- <td><a href="{item_href}">Queue
'{item_name}'</a></td>
+ <td><a href="{item_href}">{item_name}</a></td>
<td>{item_binding_key}</td>
<td class="ralign">{item_messages_matched_rate}</td>
<td class="ralign">{item_messages_matched}</td>
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/queue.py 2007-12-12 16:33:33 UTC (rev 1464)
@@ -15,22 +15,16 @@
strings = StringCatalog(__file__)
-class QueueSet(ItemSet):
+class QueueSet(PaginatedItemSet):
def __init__(self, app, name):
super(QueueSet, self).__init__(app, name)
self.unit = UnitSwitch(app, "unit")
self.add_child(self.unit)
- self.paginator = Paginator(app, "page")
- self.add_child(self.paginator)
-
def get_title(self, session, vhost):
return "Queues %s" % fmt_count(self.get_item_count(session, vhost))
- def do_process(self, session, vhost):
- self.paginator.set_count(session, self.get_item_count(session, vhost))
-
def render_unit_singular(self, session, vhost):
return self.unit.get(session) == "b" and "Byte" or
"Msg."
@@ -42,9 +36,10 @@
def do_get_items(self, session, vhost):
if vhost:
- start, end = self.paginator.get_bounds(session)
+ start, end = self.get_bounds(session)
return Queue.select(Queue.q.vhostID == vhost.id,
- join=LEFTJOINOn(None, QueueStats, Queue.q.statsCurrID ==
QueueStats.q.id),
+ join=LEFTJOINOn(None, QueueStats,
+ Queue.q.statsCurrID == QueueStats.q.id),
orderBy="name")[start:end]
def render_item_link(self, session, queue):
@@ -213,12 +208,17 @@
self.parent().show_purge(branch)
return branch.marshal()
-class QueueBindingSet(ItemSet):
+class QueueBindingSet(BindingSet):
def get_title(self, session, queue):
- return "Exchange Bindings %s" % fmt_count(len(queue.bindings))
+ return "Exchange Bindings %s" % \
+ fmt_count(self.get_item_count(session, queue))
+ def get_item_count(self, session, queue):
+ return Binding.select(Binding.q.queueID == queue.id).count()
+
def do_get_items(self, session, queue):
- return sorted_by(queue.bindings, "id")
+ start, end = self.get_bounds(session)
+ return Binding.select(Binding.q.queueID == queue.id)[start:end]
def render_item_href(self, session, binding):
branch = session.branch()
@@ -228,17 +228,6 @@
def render_item_name(self, session, binding):
return binding.exchange.name
- def render_item_binding_key(self, session, binding):
- return binding.bindingKey
-
- def render_item_messages_matched(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return stat.value(binding)
-
- def render_item_messages_matched_rate(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return fmt_rate(stat.rate(binding), "msg", "sec")
-
class QueueForm(CuminForm):
def __init__(self, app, name):
super(QueueForm, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/queue.strings 2007-12-12 16:33:33 UTC (rev 1464)
@@ -190,6 +190,9 @@
{tabs}
[QueueBindingSet.html]
+<div class="rfloat">{page}</div>
+<ul class="radiotabs"> </ul>
+
<table class="QueueBindingSet mobjects">
<tr>
<th>Exchange</th>
@@ -202,7 +205,7 @@
[QueueBindingSet.item_html]
<tr>
- <td><a href="{item_href}">Exchange
'{item_name}'</a></td>
+ <td><a href="{item_href}">{item_name}</a></td>
<td>{item_binding_key}</td>
<td class="ralign">{item_messages_matched_rate}</td>
<td class="ralign">{item_messages_matched}</td>
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/widgets.py 2007-12-12 16:33:33 UTC (rev 1464)
@@ -3,6 +3,7 @@
from wooly import *
from wooly.widgets import *
from wooly.forms import *
+from mint import *
from parameters import *
from charts import *
@@ -311,6 +312,21 @@
def render_item_content(self, session, page):
return page + 1
+class PaginatedItemSet(ItemSet):
+ def __init__(self, app, name):
+ super(PaginatedItemSet, self).__init__(app, name)
+
+ self.paginator = Paginator(app, "page")
+ self.add_child(self.paginator)
+
+ def do_process(self, session, object):
+ super(PaginatedItemSet, self).do_process(session, object)
+
+ self.paginator.set_count(session, self.get_item_count(session, object))
+
+ def get_bounds(self, session):
+ return self.paginator.get_bounds(session)
+
class SQLObjectItemSet(ItemSet):
def get_item_count(self, session, object):
items = self.get_items(session, object)
@@ -329,10 +345,35 @@
self.add_parameter(self.get_parameter())
def do_get_items(self, session, model):
- return list(BrokerGroup.select())
+ return list(BrokerGroup.select()) #XXX avoid list()ing this?
def render_item_value(self, session, group):
return group.id
def render_item_content(self, session, group):
return group.name
+
+class BindingSet(PaginatedItemSet):
+ def __init__(self, app, name):
+ super(BindingSet, self).__init__(app, name)
+
+ def get_title(self, session, queue):
+ return "Bindings"
+
+ def get_item_count(self, session, object):
+ return Binding.select().count()
+
+ def do_get_items(self, session, object):
+ start, end = self.get_bounds(session)
+ return Binding.select()[start:end]
+
+ def render_item_binding_key(self, session, binding):
+ return binding.bindingKey
+
+ def render_item_messages_matched(self, session, binding):
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return stat.value(binding)
+
+ def render_item_messages_matched_rate(self, session, binding):
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return fmt_rate(stat.rate(binding), "msg", "sec")
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/notes/justin-todo.txt 2007-12-12 16:33:33 UTC (rev 1464)
@@ -18,8 +18,6 @@
* Email amqp-list, Jonathan, and Lana with doc requirements for mgmt
- * Paginate queue bindings in exchange view
-
* Paginate producers
* Paginate consumers