[rhmessaging-commits] rhmessaging commits: r1447 - in mgmt: cumin/python/cumin and 1 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Mon Dec 10 11:56:28 EST 2007
Author: justi9
Date: 2007-12-10 11:56:28 -0500 (Mon, 10 Dec 2007)
New Revision: 1447
Modified:
mgmt/bin/quirk
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/wooly/widgets.py
Log:
Bunch of grotty changes to work better with sqlobject.
Modified: mgmt/bin/quirk
===================================================================
--- mgmt/bin/quirk 2007-12-10 14:57:57 UTC (rev 1446)
+++ mgmt/bin/quirk 2007-12-10 16:56:28 UTC (rev 1447)
@@ -1,6 +1,8 @@
#!/usr/bin/env python
-import sys, qpid, time
+import sys, qpid
+from time import sleep
+from random import random, sample, randint
class Exchange(object):
def __init__(self, session, name):
@@ -195,6 +197,17 @@
e.declare()
es.append(e)
+
+ while True:
+ sqs = sample(qs, 5)
+
+ for q in sqs:
+ m = session.message()
+ m.set("test")
+ m.send(q)
+
+ sleep(1)
+
finally:
session.close()
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-12-10 14:57:57 UTC (rev 1446)
+++ mgmt/cumin/python/cumin/broker.py 2007-12-10 16:56:28 UTC (rev 1447)
@@ -314,35 +314,77 @@
return "1.0"
class BrokerQueueTab(QueueSet):
- def get_title(self, session, broker):
- vhost = self.get_object(session, broker)
- return "Queues %s" % fmt_count(vhost and len(vhost.queues) or 0)
def get_object(self, session, broker):
broker = broker.broker # Navigate from registration to real broker
if broker:
return Vhost.selectBy(broker=broker, name="/")[0]
- class BrokerExchangeTab(ExchangeSet):
def get_title(self, session, broker):
vhost = self.get_object(session, broker)
- return "Exchanges %s" \
- % fmt_count(vhost and len(vhost.exchanges) or 0)
+ if vhost:
+ return super(BrokerView.BrokerQueueTab, self).get_title \
+ (session, vhost)
+ else:
+ return "Queues"
+ def do_process(self, session, vhost):
+ if vhost:
+ super(BrokerView.BrokerQueueTab, self).do_process \
+ (session, vhost)
+
+ def do_render(self, session, vhost):
+ if vhost:
+ return super(BrokerView.BrokerQueueTab, self).do_render \
+ (session, vhost)
+
+ class BrokerExchangeTab(ExchangeSet):
def get_object(self, session, broker):
broker = broker.broker # Navigate from registration to real broker
if broker:
return Vhost.selectBy(broker=broker, name="/")[0]
- class BrokerClientTab(ClientSet):
def get_title(self, session, broker):
vhost = self.get_object(session, broker)
- return "Clients %s" % fmt_count(vhost and len(vhost.clients) or 0)
+ if vhost:
+ return super(BrokerView.BrokerExchangeTab, self).get_title \
+ (session, vhost)
+ else:
+ return "Exchanges"
+ def do_process(self, session, vhost):
+ if vhost:
+ super(BrokerView.BrokerExchangeTab, self).do_process \
+ (session, vhost)
+
+ def do_render(self, session, vhost):
+ if vhost:
+ return super(BrokerView.BrokerExchangeTab, self).do_render \
+ (session, vhost)
+
+ class BrokerClientTab(ClientSet):
def get_object(self, session, broker):
broker = broker.broker # Navigate from registration to real broker
if broker:
return Vhost.selectBy(broker=broker, name="/")[0]
+ def get_title(self, session, broker):
+ vhost = self.get_object(session, broker)
+ if vhost:
+ return super(BrokerView.BrokerClientTab, self).get_title \
+ (session, vhost)
+ else:
+ return "Clients"
+
+ def do_process(self, session, vhost):
+ if vhost:
+ super(BrokerView.BrokerClientTab, self).do_process \
+ (session, vhost)
+
+ def do_render(self, session, vhost):
+ if vhost:
+ return super(BrokerView.BrokerClientTab, self).do_render \
+ (session, vhost)
+
class BrokerVirtualHostTab(VirtualHostSet):
def get_title(self, session, broker):
broker = broker.broker # Navigate from registration to real broker
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2007-12-10 14:57:57 UTC (rev 1446)
+++ mgmt/cumin/python/cumin/client.py 2007-12-10 16:56:28 UTC (rev 1447)
@@ -16,15 +16,26 @@
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 "Clients %s" % fmt_count(len(vhost.clients))
+ return "Clients %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_plural(self, session, vhost):
return self.unit.get(session) == "b" and "Bytes" or "Msgs."
+ def get_item_count(self, session, vhost):
+ return Client.select(Client.q.vhostID == vhost.id).count()
+
def do_get_items(self, session, vhost):
if vhost:
- return sorted_by(vhost.clients, "ipAddr")
+ start, end = self.paginator.get_bounds(session)
+ return Client.select(Client.q.vhostID == vhost.id,
+ orderBy="ipAddr")[start:end]
def render_item_link(self, session, client):
branch = session.branch()
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-12-10 14:57:57 UTC (rev 1446)
+++ mgmt/cumin/python/cumin/exchange.py 2007-12-10 16:56:28 UTC (rev 1447)
@@ -43,18 +43,22 @@
self.add_child(self.paginator)
def get_title(self, session, vhost):
- return "Exchanges %s" % fmt_count(len(vhost.exchanges))
+ return "Exchanges %s" % fmt_count(self.get_item_count(session, vhost))
def do_process(self, session, vhost):
- self.paginator.set_count(session, len(vhost.exchanges))
+ self.paginator.set_count(session, self.get_item_count(session, vhost))
def render_unit_plural(self, session, vhost):
return self.unit.get(session) == "b" and "Bytes" or "Msgs."
+ def get_item_count(self, session, vhost):
+ return Exchange.select(Exchange.q.vhostID == vhost.id).count()
+
def do_get_items(self, session, vhost):
if vhost:
start, end = self.paginator.get_bounds(session)
- return vhost.exchanges[start:end]
+ return Exchange.select(Exchange.q.vhostID == vhost.id,
+ orderBy="name")[start:end]
def render_item_link(self, session, exchange):
branch = session.branch()
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-12-10 14:57:57 UTC (rev 1446)
+++ mgmt/cumin/python/cumin/queue.py 2007-12-10 16:56:28 UTC (rev 1447)
@@ -25,10 +25,10 @@
self.add_child(self.paginator)
def get_title(self, session, vhost):
- return "Queues (%s)" % len(vhost.queues)
+ return "Queues %s" % fmt_count(self.get_item_count(session, vhost))
def do_process(self, session, vhost):
- self.paginator.set_count(session, len(vhost.queues))
+ 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."
@@ -36,10 +36,14 @@
def render_unit_plural(self, session, vhost):
return self.unit.get(session) == "b" and "Bytes" or "Msgs."
+ def get_item_count(self, session, vhost):
+ return Queue.select(Queue.q.vhostID == vhost.id).count()
+
def do_get_items(self, session, vhost):
if vhost:
start, end = self.paginator.get_bounds(session)
- return vhost.queues[start:end]
+ return Queue.select(Queue.q.vhostID == vhost.id,
+ orderBy="name")[start:end]
def render_item_link(self, session, queue):
branch = session.branch()
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2007-12-10 14:57:57 UTC (rev 1446)
+++ mgmt/cumin/python/wooly/widgets.py 2007-12-10 16:56:28 UTC (rev 1447)
@@ -126,7 +126,6 @@
self.item_tmpl = Template(self, "item_html")
def get_item_count(self, session, object):
-
return len(self.get_items(session, object))
def get_items(self, session, object):
More information about the rhmessaging-commits
mailing list