Author: justi9
Date: 2009-09-01 13:50:19 -0400 (Tue, 01 Sep 2009)
New Revision: 3609
Modified:
mgmt/trunk/cumin/python/cumin/messaging/broker.py
mgmt/trunk/cumin/python/cumin/messaging/queue.py
mgmt/trunk/cumin/python/cumin/parameters.py
Log:
Repair the broker summary view; remove some unnecessary classes
Modified: mgmt/trunk/cumin/python/cumin/messaging/broker.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/broker.py 2009-09-01 15:30:49 UTC (rev 3608)
+++ mgmt/trunk/cumin/python/cumin/messaging/broker.py 2009-09-01 17:50:19 UTC (rev 3609)
@@ -122,10 +122,7 @@
self.object = BrokerParameter(app, "id")
self.add_parameter(self.object)
- self.vhost = self.VhostAttribute(app, "vhost")
- self.add_attribute(self.vhost)
-
- self.view = BrokerView(app, "view", self.vhost)
+ self.view = BrokerView(app, "view", self.object)
self.add_mode(self.view)
self.queue = QueueFrame(app, "queue")
@@ -140,99 +137,60 @@
self.link = LinkFrame(app, "link")
self.add_mode(self.link)
- class VhostAttribute(Attribute):
- def get_default(self, session):
- broker = self.widget.object.get(session)
-
- for vhost in Vhost.selectBy(broker=broker, name="/"):
- return vhost
-
class BrokerView(CuminView):
- def __init__(self, app, name, vhost):
- super(BrokerView, self).__init__(app, name, vhost)
+ def __init__(self, app, name, broker):
+ super(BrokerView, self).__init__(app, name, broker)
- tabs = TabbedModeSet(app, "tabs")
- self.add_child(tabs)
+ self.vhost = BrokerVhostAttribute(app, "vhost", broker)
+ self.add_attribute(self.vhost)
- #tabs.add_tab(BrokerStats(app, "stats"))
- tabs.add_tab(self.BrokerQueueTab(app, "queues", vhost))
- tabs.add_tab(ExchangeSet(app, "exchanges", vhost))
- tabs.add_tab(ConnectionSet(app, "conns", vhost))
- tabs.add_tab(LinkSet(app, "links", vhost))
- tabs.add_tab(BrokerAccessControl(app, "access", vhost))
- tabs.add_tab(BrokerClustering(app, "cluster", vhost))
- tabs.add_tab(self.BrokerDetailsTab(app, "details", vhost))
+ self.tabs = TabbedModeSet(app, "tabs")
+ self.add_child(self.tabs)
- def render_group_links(self, session, object):
- return "XXX"
+ self.tabs.add_tab(QueueSet(app, "queues", self.vhost))
+ self.tabs.add_tab(ExchangeSet(app, "exchanges", self.vhost))
+ self.tabs.add_tab(ConnectionSet(app, "conns", self.vhost))
+ self.tabs.add_tab(LinkSet(app, "links", self.vhost))
+ self.tabs.add_tab(BrokerAccessControl(app, "access", self.vhost))
+ self.tabs.add_tab(BrokerClustering(app, "cluster", self.vhost))
+ self.tabs.add_tab(BrokerDetails(app, "details", self.vhost))
- links = list()
+class BrokerDetails(Widget):
+ def __init__(self, app, name, vhost):
+ super(BrokerDetails, self).__init__(app, name)
- for group in reg.groups:
- branch = session.branch()
- self.frame.frame.show_broker_group(branch, group).view.show \
- (branch)
- links.append(fmt_olink(branch, group))
+ props = self.Properties(app, "properties", vhost)
+ self.add_child(props)
- return ", ".join(links)
+ tasks = self.Tasks(app, "tasks", vhost)
+ self.add_child(tasks)
- # XXX see if we can't get rid of this
- class BrokerQueueTab(Widget):
- def __init__(self, app, name, vhost):
- super(BrokerView.BrokerQueueTab, self).__init__(app, name)
+ def render_title(self, session):
+ return "Details"
- self.__queues = QueueSet(app, "items", vhost)
- self.add_child(self.__queues)
+ class Properties(CuminProperties):
+ def do_get_items(self, session):
+ broker = self.object.get(session).broker
+ cls = self.app.model.get_class_by_object(broker)
- def render_title(self, session):
- vhost = self.frame.vhost.get(session)
- return "Queues %s" % fmt_count(vhost.queues.count())
+ props = [(x.get_title(session), x.value(session, broker))
+ for x in cls.properties]
- def render_add_queue_href(self, session):
- branch = session.branch()
- self.frame.queue.add.show(branch, None)
- return branch.marshal()
+ return props
- class BrokerLogTab(Widget):
- def render_title(self, session):
- return "Log Messages"
+ class Tasks(CuminTasks):
+ def do_get_items(self, session):
+ broker = self.object.get(session).broker
+ cls = self.app.model.get_class_by_object(broker)
- class BrokerDetailsTab(Widget):
- def __init__(self, app, name, vhost):
- super(BrokerView.BrokerDetailsTab, self).__init__(app, name)
+ tasks = [(x.get_href(session, broker),
+ x.get_title(session),
+ x.get_enabled(session, broker))
+ for x in cls.actions # XXX can't be right
+ if x.navigable and not x.aggregate]
- props = self.Properties(app, "properties", vhost)
- self.add_child(props)
+ return tasks
- tasks = self.Tasks(app, "tasks", vhost)
- self.add_child(tasks)
-
- def render_title(self, session):
- return "Details"
-
- class Properties(CuminProperties):
- def do_get_items(self, session):
- broker = self.object.get(session).broker
- cls = self.app.model.get_class_by_object(broker)
-
- props = [(x.get_title(session), x.value(session, broker))
- for x in cls.properties]
-
- return props
-
- class Tasks(CuminTasks):
- def do_get_items(self, session):
- broker = self.object.get(session).broker
- cls = self.app.model.get_class_by_object(broker)
-
- tasks = [(x.get_href(session, broker),
- x.get_title(session),
- x.get_enabled(session, broker))
- for x in cls.actions
- if x.navigable and not x.aggregate]
-
- return tasks
-
class ModuleNotEnabled(Widget):
def do_render(self, session):
return "This module is not enabled"
@@ -317,13 +275,6 @@
stats = StatSet(app, "stats", cluster, "general")
self.add_child(stats)
-class BrokerStats(Widget):
- def __init__(self, app, name):
- super(BrokerStats, self).__init__(app, name)
-
- def render_title(self, session):
- return "Statistics"
-
class BrokerBrowser(Widget):
def __init__(self, app, name):
super(BrokerBrowser, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/messaging/queue.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-09-01 15:30:49 UTC (rev 3608)
+++ mgmt/trunk/cumin/python/cumin/messaging/queue.py 2009-09-01 17:50:19 UTC (rev 3609)
@@ -71,7 +71,8 @@
self.buttons.add_child(button)
def render_title(self, session):
- return "Queues %s" % fmt_count(Queue.select().count())
+ vhost = self.vhost.get(session)
+ return "Queues %s" % fmt_count(vhost.queues.count())
def render_sql_where(self, session):
vhost = self.vhost.get(session)
Modified: mgmt/trunk/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/parameters.py 2009-09-01 15:30:49 UTC (rev 3608)
+++ mgmt/trunk/cumin/python/cumin/parameters.py 2009-09-01 17:50:19 UTC (rev 3609)
@@ -4,6 +4,16 @@
from model import Pool
from model import Job
+class ObjectAssociateAttribute(Attribute):
+ def __init__(self, app, name, object):
+ super(ObjectAssociateAttribute, self).__init__(app, name)
+
+ self.object = object
+
+ def get(self, session):
+ obj = self.object.get(session)
+ return self.get_associate(session, obj)
+
class CuminObjectParameter(Parameter):
def __init__(self, app, name, cumin_class):
self.cumin_class = cumin_class
@@ -50,6 +60,11 @@
def do_marshal(self, broker):
return str(broker.id)
+class BrokerVhostAttribute(ObjectAssociateAttribute):
+ def get_associate(self, session, broker):
+ for vhost in Vhost.selectBy(broker=broker, name="/"):
+ return vhost
+
class BrokerRegistrationParameter(Parameter):
def do_unmarshal(self, string):
return BrokerRegistration.get(int(string))
@@ -115,25 +130,15 @@
def do_marshal(self, pool):
return str(pool.id)
-class PoolAssociateAttribute(Attribute):
- def __init__(self, app, name, pool):
- super(PoolAssociateAttribute, self).__init__(app, name)
-
- self.pool = pool
-
- def get(self, session):
- pool = self.pool.get(session)
- return self.get_associate(session, pool)
-
-class PoolCollectorAttribute(PoolAssociateAttribute):
+class PoolCollectorAttribute(ObjectAssociateAttribute):
def get_associate(self, session, pool):
return pool.get_collector()
-class PoolGridAttribute(PoolAssociateAttribute):
+class PoolGridAttribute(ObjectAssociateAttribute):
def get_associate(self, session, pool):
return pool.get_grid()
-class PoolNegotiatorAttribute(PoolAssociateAttribute):
+class PoolNegotiatorAttribute(ObjectAssociateAttribute):
def get_associate(self, session, pool):
return pool.get_negotiator()