[rhmessaging-commits] rhmessaging commits: r2247 - mgmt/trunk/cumin/python/cumin.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Tue Aug 5 16:43:48 EDT 2008
Author: eallen
Date: 2008-08-05 16:43:48 -0400 (Tue, 05 Aug 2008)
New Revision: 2247
Modified:
mgmt/trunk/cumin/python/cumin/exchange.py
mgmt/trunk/cumin/python/cumin/exchange.strings
Log:
Added Remove to ExchangeSet
Made ExchangeBindingsSet a phased set (for Active, Idle, and Deleted)
Modified: mgmt/trunk/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/exchange.py 2008-08-05 20:38:22 UTC (rev 2246)
+++ mgmt/trunk/cumin/python/cumin/exchange.py 2008-08-05 20:43:48 UTC (rev 2247)
@@ -9,7 +9,7 @@
from parameters import *
from formats import *
from util import *
-
+import pdb
strings = StringCatalog(__file__)
class ExchangeInputSet(RadioInputSet):
@@ -27,15 +27,21 @@
return exchange.id
def render_item_content(self, session, exchange):
- return exchange.name
+ return exchange.name or "<em>Default</em>"
def render_item_checked_attr(self, session, exchange):
return exchange is self.param.get(session) and "checked=\"checked\""
-class ExchangeSet(CuminTable):
+class ExchangeSet(CuminTable, Form):
def __init__(self, app, name):
super(ExchangeSet, self).__init__(app, name)
+ # exchange names we don't want to allow to remove
+ skips = ["", "amq.direct", "amq.topic", "amq.fanout",
+ "amq.match", "amq.xml", "qpid.management"]
+ self.ids = FilteredCheckboxIdColumn(app, "id", self, "name", skips)
+ self.add_column(self.ids)
+
col = self.NameColumn(app, "name")
self.add_column(col)
@@ -65,6 +71,9 @@
self.phase = PhaseSwitch(app, "phase")
self.add_child(self.phase)
+ self.__remove = self.Remove(app, "remove", self)
+ self.add_child(self.__remove)
+
def get_args(self, session):
reg = self.frame.get_object(session)
return (reg.getDefaultVhost(),)
@@ -76,7 +85,7 @@
def render_title(self, session, vhost):
return "Exchanges %s" % fmt_count(vhost.exchanges.count())
-
+
def render_sql_where(self, session, vhost):
elems = list()
elems.append("e.vhost_id = %(id)r")
@@ -86,6 +95,20 @@
def get_sql_values(self, session, vhost):
return {"id": vhost.id}
+ class Remove(FormButton):
+ def process_submit(self, session):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ branch = session.branch()
+ frame = self.frame.show_exchanges_remove(branch)
+ frame.ids.set(branch, ids)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def render_content(self, session):
+ return "Remove"
+
+
class NameColumn(SqlTableColumn):
def render_title(self, session, data):
return "Name"
@@ -160,6 +183,25 @@
frame = page.show_exchange(session, exchange).show_view(session)
return frame.show_bindings(session)
+class ExchangeSetRemove(CuminBulkActionForm):
+ def process_return(self, session):
+ branch = session.branch()
+ self.frame.show_view(branch)
+ self.page.set_current_frame(branch, self.frame)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def process_item(self, session, id):
+ exchange = Exchange.get(id)
+ reg = self.frame.get_object(session)
+ action = self.app.model.exchange.remove
+ action.invoke(exchange, reg)
+
+ def render_title(self, session):
+ return "Remove Exchanges"
+
+ def render_item_content(self, session, id):
+ return "Remove Exchange '%s'" % Exchange.get(id).name
+
class ExchangeFrame(CuminFrame):
def __init__(self, app, name):
super(ExchangeFrame, self).__init__(app, name)
@@ -174,28 +216,34 @@
remove = ExchangeRemove(app, "remove")
self.add_mode(remove)
self.set_remove_mode(remove)
-
+
def render_title(self, session, exchange):
if exchange.name:
return super(ExchangeFrame, self).render_title(session, exchange)
else:
return "Default Exchange"
+ def render_href(self, session, exchange):
+ if exchange:
+ return super(ExchangeFrame, self).render_href(session, exchange)
+
+
class ExchangeRemove(CuminConfirmForm):
def get_args(self, session):
return self.frame.get_args(session)
-
- def process_cancel(self, session, reg):
+
+ def process_cancel(self, session, exchange):
branch = session.branch()
self.frame.show_view(branch)
self.page.set_redirect_url(session, branch.marshal())
- def process_submit(self, session, reg):
- action = self.app.model.broker_registration.remove
- action.invoke(reg)
+ def process_submit(self, session, exchange):
+ reg = self.frame.frame.get_object(session)
+ action = self.app.model.exchange.remove
+ action.invoke(exchange, reg)
branch = session.branch()
- self.page.show_main(branch).show_view(branch)
+ self.frame.frame.show_view(branch)
self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, exchange):
@@ -204,7 +252,7 @@
def render_submit_content(self, session, exchange):
return "Yes, Remove Exchange '%s'" % exchange.name
- def render_cancel_content(self, session, reg):
+ def render_cancel_content(self, session, exchange):
return "No, Cancel"
class ExchangeStatus(CuminStatus):
@@ -250,29 +298,103 @@
data = "model.xml?class=exchange;id=%i" % exchange.id
return "wooly.setIntervalUpdate('%s', updateExchange, 3000)" % data
-class ExchangeBindingSet(BindingSet):
- def get_args(self, session):
- return self.frame.get_args(session)
+class ExchangeBindingSet(BindingSet, Form):
+ def __init__(self, app, name):
+ super(ExchangeBindingSet, self).__init__(app, name)
+ self.__remove = self.Remove(app, "remove", self)
+ self.add_child(self.__remove)
+
+ def get_name_col(self, app):
+ return self.NameColumn(app, "q_id")
+
def render_title(self, session, exchange):
return "Queue Bindings %s" % \
- fmt_count(self.get_item_count(session, exchange))
+ fmt_count(exchange.bindings.count())
- def get_item_count(self, session, exchange):
- return exchange.bindings.count()
+ def render_sql_where(self, session, exchange):
+ elems = list()
+ elems.append("b.exchange_id = %(id)r")
+ elems.append(self.phase.get_sql_constraint(session, exchange))
+ return "where %s" % " and ".join(elems)
- def do_get_items(self, session, exchange):
- start, end = self.get_bounds(session)
- return exchange.bindings[start:end]
+ class NameColumn(SqlTableColumn):
+ def render_title(self, session, data):
+ return "Queue"
- def render_item_href(self, session, binding):
+ def render_content(self, session, data):
+ queue = Identifiable(data["q_id"])
+ branch = session.branch()
+ self.frame.frame.show_queue(branch, queue).show_view(branch)
+ return fmt_olink(branch, Queue.get(data["q_id"]))
+
+ class Remove(FormButton):
+ def process_submit(self, session):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ exchange = self.frame.get_args(session)[0]
+ branch = session.branch()
+ frame = self.frame.frame.show_exchange_bindings_remove(branch, exchange)
+ frame.ids.set(branch, ids)
+ self.page.set_redirect_url(session, branch.marshal())
+
+ def render_content(self, session):
+ return "Remove"
+
+class BindingSetRemove(CuminBulkActionForm):
+ def process_item(self, session, id):
+ binding = Binding.get(id)
+ action = self.app.model.binding.remove
+ action.invoke(binding)
+
+ def render_title(self, session):
+ return "Remove Binding"
+
+ def render_form_heading(self, session, *args):
+ return "Remove Binding between:"
+
+ def render_item_content(self, session, id):
+ binding = Binding.get(id)
+ ename = binding.exchange.name or "Default"
+ qname = binding.queue.name
+ return "Exchange: %s <i>and</i> Queue: %s" % (ename, qname)
+
+class ExchangeBindingSetRemove(BindingSetRemove):
+ def __init__(self, app, name):
+ super(ExchangeBindingSetRemove, self).__init__(app, name)
+
+ self.__exchange = None
+
+ def set_exchange(self, exchange):
+ self.__exchange = exchange
+
+ def process_return(self, session):
branch = session.branch()
- self.frame.frame.show_queue(branch, binding.queue)
- return branch.marshal()
+ if self.__exchange:
+ mode = self.frame.show_exchange(branch, self.__exchange)
+ mode.show_view(branch).show_bindings(branch)
+ else:
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
+
+class QueueBindingSetRemove(BindingSetRemove):
+ def __init__(self, app, name):
+ super(QueueBindingSetRemove, self).__init__(app, name)
- def render_item_name(self, session, binding):
- if binding.queue:
- return binding.queue.name
+ self.__queue = None
+
+ def set_queue(self, queue):
+ self.__queue = queue
+
+ def process_return(self, session):
+ branch = session.branch()
+ if self.__queue:
+ mode = self.frame.show_queue(branch, self.__queue)
+ mode.show_view(branch).show_bindings(branch)
+ else:
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
class ExchangeForm(CuminFieldForm):
def __init__(self, app, name):
@@ -338,7 +460,7 @@
exchange.type = self.type.get(session)
action = self.app.model.exchange.add
- action.invoke(reg, exchange)
+ action.invoke(exchange, reg)
self.process_cancel(session)
@@ -372,33 +494,6 @@
def render_title(self, session, exchange):
return "Edit Exchange '%s'" % exchange.name
-class ExchangeRemove(CuminConfirmForm):
- def get_args(self, session):
- return self.frame.get_args(session)
-
- def process_cancel(self, session, exchange):
- branch = session.branch()
- self.page.show_exchange(branch, exchange).show_view(branch)
- session.set_redirect(branch.marshal())
-
- def process_submit(self, session, exchange):
- vhost = exchange.get_virtual_host()
-
- exchange.remove()
-
- branch = session.branch()
- self.page.show_broker(branch, vhost.get_broker()).show_view(branch)
- self.page.set_redirect_url(session, branch.marshal())
-
- def render_title(self, session, exchange):
- return "Remove Exchange '%s'" % exchange.name
-
- def render_submit_content(self, session, exchange):
- return "Yes, Remove Exchange '%s'" % exchange.name
-
- def render_cancel_content(self, session, exchange):
- return "No, Cancel"
-
class ExchangeStats(TabbedModeSet):
def __init__(self, app, name):
super(ExchangeStats, self).__init__(app, name)
Modified: mgmt/trunk/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/exchange.strings 2008-08-05 20:38:22 UTC (rev 2246)
+++ mgmt/trunk/cumin/python/cumin/exchange.strings 2008-08-05 20:43:48 UTC (rev 2247)
@@ -32,6 +32,7 @@
{sql_orderby}
{sql_limit}
+
[ExchangeSet.count_sql]
select count(*)
from exchange as e
@@ -46,27 +47,35 @@
}
[ExchangeSet.html]
+<form id="{id}" method="post" action="?">
-<ul class="actions">
- <li><a class="nav" href="{add_exchange_url}">Add New Exchange</a></li>
- </ul>
-
-<div class="rfloat">{phase}</div>
-{unit}
+ <ul class="actions">
+ <li><a class="nav" href="{add_exchange_url}">Add New Exchange</a></li>
+ </ul>
+
+ <div class="rfloat">{phase}</div>
+ {unit}
+
+ <div class="sactions">
+ <h2>Act on Selected Exchanges:</h2>
+ {remove}
+ </div>
+
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+ </table>
+ <div>{hidden_inputs}</div>
+</form>
-<table class="mobjects">
- <thead>
- <tr>
- <th class="setnav" colspan="{column_count}">
- <div class="rfloat">{page}</div>
- {count}
- </th>
- </tr>
- <tr>{headers}</tr>
- </thead>
- <tbody>{items}</tbody>
-</table>
-
[ExchangeSet.item_html]
<tr>{cells}</tr>
@@ -178,27 +187,51 @@
cumin.runObjectListeners(exchange);
}
+[ExchangeBindingSet.sql]
+select
+ b.id,
+ b.queue_id as q_id,
+ b.binding_key as key
+from binding as b
+left outer join binding_stats as c on c.id = b.stats_curr_id
+{sql_where}
+{sql_orderby}
+{sql_limit}
+
+[ExchangeBindingSet.count_sql]
+select count(*)
+from binding as b
+left outer join binding_stats as c on c.id = b.stats_curr_id
+{sql_where}
+
[ExchangeBindingSet.html]
-<div class="rfloat">{page}</div>
-<ul class="radiotabs"> </ul>
+<form id="{id}" method="post" action="?">
-<table class="ExchangeBindingSet mobjects">
- <tr>
- <th>Queue</th>
- <th>Key</th>
- <th class="ralign" colspan="2">Messages Matched</th>
- </tr>
+ <div class="rfloat">{phase}</div>
+ <ul class="radiotabs"><li> </li></ul>
+
+ <div class="sactions">
+ <h2>Act on Selected Bindings:</h2>
+ {remove}
+ </div>
+
+ <table class="mobjects">
+ <thead>
+ <tr>
+ <th class="setnav" colspan="{column_count}">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
+ </table>
+ <div>{hidden_inputs}</div>
+</form>
- {items}
-</table>
-
[ExchangeBindingSet.item_html]
-<tr>
- <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>
-</tr>
+<tr>{cells}</tr>
[ExchangeStats.html]
<table class="twocol">
More information about the rhmessaging-commits
mailing list