[rhmessaging-commits] rhmessaging commits: r1554 - in mgmt: cumin/python/wooly and 1 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Sat Jan 12 17:35:40 EST 2008
Author: justi9
Date: 2008-01-12 17:35:40 -0500 (Sat, 12 Jan 2008)
New Revision: 1554
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/broker.strings
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/client.strings
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/parameters.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/cumin/widgets.strings
mgmt/cumin/python/wooly/parameters.py
mgmt/cumin/python/wooly/tables.py
mgmt/notes/errors.txt
mgmt/notes/justin-todo.txt
Log:
Adds bulk operation support:
- Purge queues
- Close clients
- Close sessions
- Detach sessions
- Unregister brokers
Converts the brokers table to a custom-sql backing.
Adds a CuminBulkActionForm for confirming some bulk actions.
Adds a CheckboxIdColumn for creating checkboxable lists of items to
act on.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/broker.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -16,130 +16,107 @@
strings = StringCatalog(__file__)
-class BrokerSet(PaginatedItemSet, Form, Frame):
+class BrokerSet(CuminTable, Form):
def __init__(self, app, name):
super(BrokerSet, self).__init__(app, name)
- self.broker = BrokerParameter(app, "param")
- self.add_parameter(self.broker)
- self.add_form_parameter(self.broker)
+ self.table_sql = "broker_registration as b"
- self.brokers = ListParameter(app, "id", self.broker)
- self.add_parameter(self.brokers)
- self.add_form_parameter(self.brokers)
+ self.add_sql_column("id", "b.id")
+ self.add_sql_column("name", "b.name")
- self.action = Parameter(app, "action")
- self.add_parameter(self.action)
- self.add_form_parameter(self.action)
+ self.ids = CheckboxIdColumn(app, "id")
+ self.add_column(self.ids)
+ self.add_form_parameter(self.ids)
+ col = self.NameColumn(app, "name")
+ self.add_column(col)
+
+ col = self.GroupsColumn(app, "groups")
+ self.add_column(col)
+
self.groups = self.BrokerSetGroupInput(app, "groups", self)
self.add_child(self.groups)
+ # XXX get rid of this
self.submit = BooleanParameter(app, "submit")
self.add_parameter(self.submit)
self.add_form_parameter(self.submit)
+ self.__unregister = self.Unregister(app, "unregister", self)
+ self.add_child(self.__unregister)
+
def get_title(self, session, model):
- return "Brokers %s" % fmt_count(self.get_item_count(session, model))
+ count = BrokerRegistration.select().count()
+ return "Brokers %s" % fmt_count(count)
def get_item_count(self, session, model):
return BrokerRegistration.select().count()
- def do_get_items(self, session, model):
- start, end = self.get_bounds(session)
- return BrokerRegistration.select(orderBy="name")[start:end]
+ class Unregister(FormButton):
+ def render_content(self, session, model):
+ return "Unregister"
- def do_process(self, session, model):
- super(BrokerSet, self).do_process(session, model)
+ def process_submit(self, session, model):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
- if self.submit.get(session):
- self.submit.set(session, False)
+ branch = session.branch()
+ frame = self.frame().show_brokers_remove(branch)
+ frame.ids.set(branch, ids)
+ self.page().set_redirect_url(session, branch.marshal())
- brokers = self.brokers.get(session)
- action = self.action.get(session)
+ class Groupify(FormButton):
+ def render_content(self, session, model):
+ return "Add to Group"
- if action == "remove":
- branch = session.branch()
- frame = self.page().show_broker_set_remove(branch)
- frame.set_brokers(branch, brokers)
- self.page().set_redirect_url(session, branch.marshal())
- else:
- group = self.groups.get(session)
+ def process_submit(self, session, model):
+ group = self.parent.groups.get(session)
- if group:
- for broker in brokers:
- try:
- broker.addBrokerGroup(group)
- except IntegrityError:
- pass
+ if group:
+ for broker in brokers:
+ try:
+ broker.addBrokerGroup(group)
+ except IntegrityError:
+ pass
- self.page().set_redirect_url(session, session.marshal())
+ self.page().set_redirect_url(session, session.marshal())
- def render_action_param_name(self, session, broker):
- return self.action.path()
+ class NameColumn(SqlTableColumn):
+ def get_title(self, session, model):
+ return "Name"
- def render_submit_param_name(self, session, broker):
- return self.submit.path()
+ def render_content(self, session, data):
+ broker = Identifiable(data["id"])
+ branch = session.branch()
+ self.frame().show_broker(branch, broker).show_view(branch)
+ return fmt_olink(branch, broker, name=data["name"])
- def render_item_checkbox_name(self, session, broker):
- return self.brokers.path()
+ class GroupsColumn(SqlTableColumn):
+ def get_title(self, session, model):
+ return "Groups"
- def render_item_checkbox_value(self, session, broker):
- return self.broker.marshal(broker)
+ def render_content(self, session, data):
+ broker = BrokerRegistration.get(data["id"])
+ count = broker.groups.count()
- def render_item_checkbox_checked_attr(self, session, broker):
- return broker in self.brokers.get(session) and "checked=\"checked\""
+ if count == 0:
+ link = fmt_none()
+ elif count < 3:
+ links = list()
- def render_item_link(self, session, broker):
- branch = session.branch()
- self.page().show_broker(branch, broker).show_view(branch)
- return fmt_olink(branch, broker)
+ for group in broker.groups[:2]:
+ branch = session.branch()
+ frame = self.frame().show_broker_group(branch, group)
+ frame.show_view(branch)
+ links.append(fmt_olink(branch, group))
- def render_item_group_links(self, session, broker):
- count = broker.groups.count()
+ link = ", ".join(links)
+ else:
+ link = "%i groups" % count
- if count == 0:
- link = fmt_none()
- elif count < 3:
- links = list()
+ return link
- for group in broker.groups[:2]:
- branch = session.branch()
- self.page().show_broker_group(branch, group).show_view(branch)
- links.append(fmt_olink(branch, group))
-
- link = ", ".join(links)
- else:
- link = "%i groups" % count
-
- return link
-
- def render_item_profile_link(self, session, broker):
- profile = broker.profile
-
- if profile:
- branch = session.branch()
- self.page().show_broker_profile(branch, profile).show_view(branch)
- return fmt_olink(branch, profile)
- else:
- return fmt_none()
-
- def render_item_cluster_link(self, session, broker):
- cluster = broker.cluster
-
- if cluster:
- branch = session.branch()
- self.page().show_broker_cluster(branch, cluster).show_view(branch)
- return fmt_olink(branch, cluster)
- else:
- return fmt_none()
-
- def render_item_status(self, session, broker):
- return fmt_ostatus(broker)
-
- def render_item_load(self, session, broker):
- return "%.2f" % random()
-
class BrokerSetGroupInput(BrokerGroupInput):
pass
@@ -165,12 +142,18 @@
self.queue = QueueFrame(app, "queue")
self.add_mode(self.queue)
+ self.queues_purge = QueueSetPurge(app, "queuespurge")
+ self.add_mode(self.queues_purge)
+
self.exchange = ExchangeFrame(app, "exchange")
self.add_mode(self.exchange)
self.client = ClientFrame(app, "client")
self.add_mode(self.client)
+ self.clients_close = ClientSetClose(app, "clientsclose")
+ self.add_mode(self.clients_close)
+
def show_config_property(self, session, prop):
self.prop.set_config_property(session, prop)
self.page().set_current_frame(session, self.prop)
@@ -181,6 +164,10 @@
self.page().set_current_frame(session, self.queue)
return self.show_mode(session, self.queue)
+ def show_queues_purge(self, session):
+ self.page().set_current_frame(session, self.queues_purge)
+ return self.show_mode(session, self.queues_purge)
+
def show_exchange(self, session, exchange):
self.exchange.set_object(session, exchange)
self.page().set_current_frame(session, self.exchange)
@@ -191,6 +178,10 @@
self.page().set_current_frame(session, self.client)
return self.show_mode(session, self.client)
+ def show_clients_close(self, session):
+ self.page().set_current_frame(session, self.clients_close)
+ return self.show_mode(session, self.clients_close)
+
def get_title(self, session, broker):
return "Broker '%s'" % broker.name
@@ -720,45 +711,22 @@
def render_cancel_content(self, session, broker):
return "No, Cancel"
-class BrokerSetRemove(CuminActionSetForm, Frame):
- def __init__(self, app, name):
- super(BrokerSetRemove, self).__init__(app, name)
-
- # Note that the params below are not "form params", so we
- # don't use add_form_parameter to exclude them from the
- # marshalled set
-
- param = BrokerParameter(app, "param")
- self.add_parameter(param)
-
- self.brokers = ListParameter(app, "id", param)
- self.add_parameter(self.brokers)
-
+class BrokerSetRemove(CuminBulkActionForm, Frame):
def get_title(self, session, model):
return "Unregister Brokers"
- def set_brokers(self, session, brokers):
- self.brokers.set(session, brokers)
+ def process_item(self, session, id):
+ try:
+ broker = BrokerRegistration.get(id)
+ broker.destroySelf()
+ except Exception, e:
+ # In an extra ui step, note any errors that arose
+ print e
- def process_cancel(self, session, model):
+ def process_return(self, session, id):
branch = session.branch()
- self.page().show_view(branch)
+ self.frame().show_view(branch)
self.page().set_redirect_url(session, branch.marshal())
- def process_submit(self, session, model):
- brokers = self.brokers.get(session)
-
- for broker in brokers:
- try:
- broker.destroySelf()
- except Exception, e:
- # In an extra ui step, note any errors that arose
- print e
-
- self.process_cancel(session, model)
-
- def get_items(self, session, model):
- return self.brokers.get(session)
-
- def render_item_content(self, session, broker):
- return "Unregister Broker '%s'" % broker.name
+ def render_item_content(self, session, id):
+ return "Unregister Broker '%s'" % BrokerRegistration.get(id).name
Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/broker.strings 2008-01-12 22:35:40 UTC (rev 1554)
@@ -2,51 +2,29 @@
<form id="{id}" method="post" action="?">
<!-- <select onchange="document.getElementById('{id}.submit').submit()"> -->
- <div style="float: right; position: relative; top: -2em;">{page}</div>
-
<div class="sactions">
<h2>Act on Selected Brokers:</h2>
+ {unregister}
- <select name="{action_param_name}" onchange="submit()">
- <option value="">Choose Action...</option>
- <option value="remove">Unregister</option>
- </select>
-
<h2>Add to Group:</h2>
-
{groups}
</div>
<table class="mobjects">
- <tr>
- <th></th>
- <th>Name</th>
-<!--
- <th>Profile</th>
- <th>Cluster</th>
--->
- <th>Groups</th>
- <th>Status</th>
- </tr>
-
- {items}
+ <thead>
+ <tr>
+ <th class="setnav" colspan="0">
+ <div class="rfloat">{page}</div>
+ {count}
+ </th>
+ </tr>
+ <tr>{headers}</tr>
+ </thead>
+ <tbody>{items}</tbody>
</table>
- <input type="hidden" name="{submit_param_name}" value="t"/>
{hidden_inputs}
</form>
-[BrokerSet.item_html]
-<tr>
- <td><input type="checkbox" name="{item_checkbox_name}" value="{item_checkbox_value}" {item_checkbox_checked_attr}/></td>
- <td>{item_link}</td>
-<!--
- <td>{item_profile_link}</td>
- <td>{item_cluster_link}</td>
--->
- <td>{item_group_links}</td>
- <td>{item_status}</td>
-</tr>
-
[BrokerConfigTab.css]
.BrokerConfigTab.diff {
background-color: #ff9;
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/client.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -11,7 +11,7 @@
strings = StringCatalog(__file__)
-class ClientSet(CuminTable):
+class ClientSet(CuminTable, Form):
def __init__(self, app, name):
super(ClientSet, self).__init__(app, name)
@@ -35,13 +35,13 @@
"(c.frames_to_client - p.frames_to_client)" +
" / extract(epoch from (c.rec_time - p.rec_time))");
- col = CheckboxColumn(app, "id")
- self.add_column(col)
+ self.ids = CheckboxIdColumn(app, "id")
+ self.add_column(self.ids)
col = self.AddressColumn(app, "addr")
self.add_column(col)
- self.set_selected_column(col)
+ self.set_default_column(col)
#col = self.SessionsColumn(app, "sess")
#self.add_column(col)
@@ -57,9 +57,12 @@
self.unit.add_state("f", "Frames")
self.add_child(self.unit)
- self.phase = PhaseSwitch(app, "phase")
- self.add_child(self.phase)
+ self.__phase = PhaseSwitch(app, "phase")
+ self.add_child(self.__phase)
+ self.__close = self.Close(app, "close", self)
+ self.add_child(self.__close)
+
def get_title(self, session, vhost):
return "Clients %s" % fmt_count(vhost.clients.count())
@@ -70,7 +73,7 @@
elems = list()
elems.append("l.vhost_id = %(id)r")
- phase = self.phase.get(session)
+ phase = self.__phase.get(session)
if phase == "a":
elems.append("c.rec_time > now() - interval '10 minutes'")
@@ -85,6 +88,19 @@
def get_sql_values(self, session, vhost):
return {"id": vhost.id}
+ class Close(FormButton):
+ def render_content(self, session, object):
+ return "Close"
+
+ def process_submit(self, session, model):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ branch = session.branch()
+ frame = self.frame().show_clients_close(branch)
+ frame.ids.set(branch, ids)
+ self.page().set_redirect_url(session, branch.marshal())
+
class AddressColumn(SqlTableColumn):
def get_title(self, session, vhost):
return "Address"
@@ -145,15 +161,28 @@
self.close = ClientClose(app, "close")
self.add_mode(self.close)
+ self.sessions_detach = ClientSessionSetDetach(app, "sessionsdetach")
+ self.add_mode(self.sessions_detach)
+
+ self.sessions_close = ClientSessionSetClose(app, "sessionsclose")
+ self.add_mode(self.sessions_close)
+
def show_close(self, session):
return self.show_mode(session, self.close)
+ def show_sessions_detach(self, session):
+ return self.show_mode(session, self.sessions_detach)
+
+ def show_sessions_close(self, session):
+ return self.show_mode(session, self.sessions_close)
+
def get_title(self, session, client):
return "Client %s" % client.address
def doit(error, args):
- print error, args
- print "did it!"
+ pass
+ #print error, args
+ #print "did it!"
class ClientClose(CuminConfirmForm):
def get_title(self, session, client):
@@ -161,7 +190,7 @@
def process_cancel(self, session, client):
branch = session.branch()
- self.page().show_client(branch, client).show_view(branch)
+ self.frame().show_view(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, client):
@@ -178,6 +207,22 @@
def render_cancel_content(self, session, client):
return "No, Cancel"
+class ClientSetClose(CuminBulkActionForm):
+ def get_title(self, session, object):
+ return "Close Clients"
+
+ def process_return(self, session, object):
+ branch = session.branch()
+ self.frame().show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_item(self, session, id):
+ try:
+ client = Client.get(id)
+ client.close(self.app.model.data, client.managedBroker, doit)
+ except Exception, e:
+ self.add_error(session, e)
+
class ClientStatus(CuminStatus):
def render_frames_from(self, session, client):
stat = self.app.model.client.get_stat("framesFromClient")
@@ -268,7 +313,45 @@
def get_title(self, session, client):
return "History"
-class ClientSessionSet(CuminTable):
+class ClientSessionSetDetach(CuminBulkActionForm, Frame):
+ def get_title(self, session, object):
+ return "Detach Sessions"
+
+ def process_item(self, session, id):
+ try:
+ session_ = Session.get(id)
+ session_.detach(self.app.model.data, session_.managedBroker, doit)
+ except Exception, e:
+ self.add_error(session, e)
+
+ def process_cancel(self, session, object):
+ branch = session.branch()
+ self.frame().show_view(branch).show_sessions(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_return(self, session, object):
+ self.process_cancel(session, object)
+
+class ClientSessionSetClose(CuminBulkActionForm, Frame):
+ def get_title(self, session, object):
+ return "Close Sessions"
+
+ def process_item(self, session, id):
+ try:
+ session_ = Session.get(id)
+ session_.close(self.app.model.data, session_.managedBroker, doit)
+ except Exception, e:
+ self.add_error(session, e)
+
+ def process_cancel(self, session, object):
+ branch = session.branch()
+ self.frame().show_view(branch).show_sessions(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_return(self, session, object):
+ self.process_cancel(session, object)
+
+class ClientSessionSet(CuminTable, Form):
def __init__(self, app, name):
super(ClientSessionSet, self).__init__(app, name)
@@ -277,22 +360,34 @@
self.add_sql_join("session_stats as c", "c.id", "s.stats_curr_id")
self.add_sql_join("session_stats as p", "p.id", "s.stats_curr_id")
+ self.add_sql_column("id", "s.id")
self.add_sql_column("name", "s.name")
self.add_sql_column("expires", "c.expire_time")
self.add_sql_column("status", "c.attached")
+ self.ids = CheckboxIdColumn(app, "id")
+ self.add_column(self.ids)
+
col = self.NameColumn(app, "name")
self.add_column(col)
+ self.set_default_column(col)
+
col = self.ExpiresColumn(app, "expires")
self.add_column(col)
col = self.StatusColumn(app, "status")
self.add_column(col)
- self.phase = PhaseSwitch(app, "phase")
- self.add_child(self.phase)
+ self.__phase = PhaseSwitch(app, "phase")
+ self.add_child(self.__phase)
+ self.__detach = self.Detach(app, "detach", self)
+ self.add_child(self.__detach)
+
+ self.__close = self.Close(app, "close", self)
+ self.add_child(self.__close)
+
def get_title(self, session, client):
return "Sessions %s" % fmt_count(client.sessions.count())
@@ -300,7 +395,7 @@
elems = list()
elems.append("s.client_id = %(id)r")
- phase = self.phase.get(session)
+ phase = self.__phase.get(session)
if phase == "a":
elems.append("c.rec_time > now() - interval '10 minutes'")
@@ -315,6 +410,34 @@
def get_sql_values(self, session, client):
return {"id": client.id}
+ class Detach(FormButton):
+ def render_content(self, session, object):
+ return "Detach"
+
+ def process_submit(self, session, model):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ branch = session.branch()
+ frame = self.frame().show_sessions_detach(branch)
+ frame.ids.set(branch, ids)
+ self.page().set_current_frame(branch, frame)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ class Close(FormButton):
+ def render_content(self, session, object):
+ return "Close"
+
+ def process_submit(self, session, model):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ branch = session.branch()
+ frame = self.frame().show_sessions_close(branch)
+ frame.ids.set(branch, ids)
+ self.page().set_current_frame(branch, frame)
+ self.page().set_redirect_url(session, branch.marshal())
+
class NameColumn(SqlTableColumn):
def get_title(self, session, object):
return "Name"
@@ -328,8 +451,11 @@
class StatusColumn(SqlTableColumn):
def get_title(self, session, object):
- return "Status"
+ return "Attached?"
+ def render_value(self, session, value):
+ return fmt_predicate(value)
+
class ClientXmlPage(CuminXmlPage):
def __init__(self, app, name):
super(ClientXmlPage, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/client.strings 2008-01-12 22:35:40 UTC (rev 1554)
@@ -1,13 +1,12 @@
[ClientSet.html]
-<form>
+<form id="{id}" method="post" action="?">
<div class="rfloat">{phase}</div>
{unit}
<div class="sactions">
<h2>Act on Selected Clients:</h2>
- <button>Close</button>
- <button>Detach</button>
+ {close}
</div>
<table class="mobjects">
@@ -22,6 +21,7 @@
</thead>
<tbody>{items}</tbody>
</table>
+ {hidden_inputs}
</form>
[ClientStatus.javascript]
@@ -132,17 +132,15 @@
<div class="iblock chart">{received}</div>
[ClientSessionSet.html]
-<form>
+<form id="{id}" method="post" action="?">
<div class="rfloat">{phase}</div>
- <ul class="radiotabs"><li> </li></ul>
+ <ul class="radiotabs"><li> </li></ul>
<div class="sactions">
<h2>Act on Selected Sessions:</h2>
- <button>Solicit Ack</button>
- <button>Reset Lifespan</button>
- <button>Detach</button>
- <button>Close</button>
+ {detach}
+ {close}
</div>
<table class="mobjects">
@@ -157,4 +155,5 @@
</thead>
<tbody>{items}</tbody>
</table>
+ {hidden_inputs}
</form>
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/page.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -35,8 +35,8 @@
self.broker_add = BrokerAdd(app, "brokeradd")
self.add_mode(self.broker_add)
- self.broker_set_remove = BrokerSetRemove(app, "brokersrem")
- self.add_mode(self.broker_set_remove)
+ self.brokers_remove = BrokerSetRemove(app, "brokersremove")
+ self.add_mode(self.brokers_remove)
self.group = BrokerGroupFrame(app, "group")
self.add_mode(self.group)
@@ -93,8 +93,8 @@
frame = self.show_mode(session, self.broker_add)
return self.set_current_frame(session, frame)
- def show_broker_set_remove(self, session):
- frame = self.show_mode(session, self.broker_set_remove)
+ def show_brokers_remove(self, session):
+ frame = self.show_mode(session, self.brokers_remove)
return self.set_current_frame(session, frame)
def show_broker_group(self, session, group):
Modified: mgmt/cumin/python/cumin/parameters.py
===================================================================
--- mgmt/cumin/python/cumin/parameters.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/parameters.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -69,6 +69,13 @@
def do_marshal(self, queue):
return str(queue.id)
+class SessionParameter(Parameter):
+ def do_unmarshal(self, string):
+ return Session.get(int(string))
+
+ def do_marshal(self, session):
+ return str(session.id)
+
class VirtualHostParameter(Parameter):
def do_unmarshal(self, string):
return Vhost.get(int(string))
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/queue.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -16,7 +16,7 @@
strings = StringCatalog(__file__)
-class QueueSet(CuminTable):
+class QueueSet(CuminTable, Form):
def __init__(self, app, name):
super(QueueSet, self).__init__(app, name)
@@ -46,13 +46,13 @@
self.add_sql_column("mdepthaccel", "1")
self.add_sql_column("bdepthaccel", "1")
- col = CheckboxColumn(app, "id")
- self.add_column(col)
+ self.ids = CheckboxIdColumn(app, "id")
+ self.add_column(self.ids)
col = self.NameColumn(app, "name")
self.add_column(col)
- self.set_selected_column(col)
+ self.set_default_column(col)
col = self.ConsumersColumn(app, "consumers")
self.add_column(col)
@@ -75,6 +75,9 @@
self.phase = PhaseSwitch(app, "phase")
self.add_child(self.phase)
+ self.__purge = self.Purge(app, "purge", self)
+ self.add_child(self.__purge)
+
def get_title(self, session, vhost):
return "Queues %s" % fmt_count(vhost.queues.count())
@@ -97,6 +100,19 @@
def get_sql_values(self, session, vhost):
return {"id": vhost.id}
+ class Purge(FormButton):
+ def process_submit(self, session, object):
+ ids = self.parent.ids.get(session)
+ self.parent.ids.clear(session)
+
+ branch = session.branch()
+ frame = self.frame().show_queues_purge(branch)
+ frame.ids.set(branch, ids)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def render_content(self, session, object):
+ return "Purge"
+
class NameColumn(SqlTableColumn):
def get_title(self, session, object):
return "Name"
@@ -430,7 +446,7 @@
def process_cancel(self, session, queue):
branch = session.branch()
- self.page().show_queue(branch, queue).show_view(branch)
+ self.frame().show_view(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, queue):
@@ -447,6 +463,23 @@
def render_cancel_content(self, session, queue):
return "No, Cancel"
+class QueueSetPurge(CuminBulkActionForm):
+ def get_title(self, session, object):
+ return "Purge Queues"
+
+ def process_return(self, session, object):
+ branch = session.branch()
+ self.frame().show_view(branch)
+ # XXX need to set current frame here?
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_item(self, session, id):
+ try:
+ queue = Queue.get(id)
+ queue.purge(self.app.model.data, queue.managedBroker, doit)
+ except Exception, e:
+ self.add_error(session, e)
+
class QueueBindingAdd(CuminForm):
def __init__(self, app, name):
super(QueueBindingAdd, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/queue.strings 2008-01-12 22:35:40 UTC (rev 1554)
@@ -1,12 +1,12 @@
[QueueSet.html]
-<form>
+<form id="{id}" method="post" action="?">
<div class="rfloat">{phase}</div>
{unit}
<div class="sactions">
<h2>Act on Selected Queues:</h2>
- <button>Purge Messages</button>
+ {purge}
</div>
<table class="mobjects">
@@ -21,6 +21,7 @@
</thead>
<tbody>{items}</tbody>
</table>
+ {hidden_inputs}
</form>
[QueueForm.html]
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/widgets.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -138,6 +138,39 @@
def __init__(self, app, name):
super(CuminActionSetForm, self).__init__(app, name)
+class CuminBulkActionForm(ItemSet, CuminForm, Frame):
+ def __init__(self, app, name):
+ super(CuminBulkActionForm, self).__init__(app, name)
+
+ param = IntegerParameter(app, "param")
+ self.add_parameter(param)
+
+ self.ids = ListParameter(app, "id", param)
+ self.add_parameter(self.ids)
+
+ def get_items(self, session, object):
+ return self.ids.get(session)
+
+ def process_submit(self, session, object):
+ items = self.get_items(session, object)
+
+ for item in items:
+ self.process_item(session, item)
+
+ self.process_return(session, object)
+
+ def process_item(self, session, item):
+ print "processing item", item
+
+ def process_return(self, session, object):
+ pass
+
+ def process_cancel(self, session, object):
+ self.process_return(session, object)
+
+ def render_item_content(self, session, id):
+ return "Act on object %i" % id
+
class CuminStatus(Widget):
def render_class(self, session, object):
if hasattr(object, "errors"):
@@ -452,3 +485,27 @@
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 CheckboxIdColumn(SqlTableColumn):
+ def __init__(self, app, name):
+ super(CheckboxIdColumn, self).__init__(app, name)
+
+ param = IntegerParameter(app, "param")
+ self.add_parameter(param)
+
+ self.__list = ListParameter(app, "id", param)
+ self.add_parameter(self.__list)
+
+ def get(self, session):
+ return self.__list.get(session)
+
+ def clear(self, session):
+ self.__list.set(session, list())
+
+ def do_render(self, session, data):
+ name = self.__list.path()
+ id = data[self.name]
+ attr = id in self.__list.get(session) and "checked=\"checked\"" or ""
+ t = "<td><input type=\"checkbox\" name=\"%s\" value=\"%i\" %s/></td>"
+
+ return t % (name, id, attr)
Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/cumin/widgets.strings 2008-01-12 22:35:40 UTC (rev 1554)
@@ -40,6 +40,32 @@
[CuminActionSetForm.item_html]
<li>{item_content}</li>
+[CuminBulkActionForm.html]
+<form id="{id}" class="mform" method="post" action="?">
+ <div class="head">
+ <h1>{title}</h1>
+ </div>
+ <div class="body">
+ <span class="legend">Actions</span>
+ <fieldset>
+ <ul>{items}</ul>
+ </fieldset>
+
+ {hidden_inputs}
+ </div>
+ <div class="foot">
+ <div style="display: block; float: left;"><button>Help</button></div>
+ {cancel}
+ {submit}
+ </div>
+</form>
+<script>
+ wooly.doc().elembyid("{id}").node.elements[0].focus();
+</script>
+
+[CuminBulkActionForm.item_html]
+<li>{item_content}</li>
+
[CuminStatus.javascript]
function updateStatus(id, object) {
var status = wooly.doc().elembyid(id);
Modified: mgmt/cumin/python/wooly/parameters.py
===================================================================
--- mgmt/cumin/python/wooly/parameters.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/wooly/parameters.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -11,6 +11,9 @@
self.is_collection = True
+ def set_element_parameter(self, param):
+ self.param = param
+
def get_default(self, session):
return copy(self.default)
Modified: mgmt/cumin/python/wooly/tables.py
===================================================================
--- mgmt/cumin/python/wooly/tables.py 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/cumin/python/wooly/tables.py 2008-01-12 22:35:40 UTC (rev 1554)
@@ -33,7 +33,7 @@
if column.name == name:
return column
- def set_selected_column(self, column):
+ def set_default_column(self, column):
self.scolumn.default = column.name
def is_reversed(self, session):
@@ -171,8 +171,13 @@
self.get_orderby_sql(session),
self.get_limit_sql(session))
- return self.build_sql(elems)
+ sql = self.build_sql(elems)
+ #print "sql -----------------------"
+ #print sql
+
+ return sql
+
def get_count_sql(self, session):
elems = ("select count(*)",
self.get_from_sql(session),
@@ -293,7 +298,7 @@
dir = self.parent.is_reversed(session) and "desc" or "asc"
return "order by %s %s" % (key, dir)
-class CheckboxColumn(ItemTableColumn):
+class CheckboxColumn(SqlTableColumn):
def do_render(self, session, data):
return "<td><input type=\"checkbox\" name=\"%s\"/></td>" % \
data[self.name]
Modified: mgmt/notes/errors.txt
===================================================================
--- mgmt/notes/errors.txt 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/notes/errors.txt 2008-01-12 22:35:40 UTC (rev 1554)
@@ -1,3 +1,34 @@
[justin at localhost cumindev]$ cumindev-etags
/home/justin/cumindev/cumin/python/cumin/.#model.py: No such file or directory
+APPLICATION ERROR
+
+----- python trace -----
+Traceback (most recent call last):
+ File "/home/jross/mgmt/cumin/python/wooly/server.py", line 83, in service
+ response = page.render(session, None)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 255, in render
+ string = self.do_render(session, object)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 265, in do_render
+ self.__main_tmpl.render(session, object, writer)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 791, in render
+ result = elem(self.widget, session, object)
+ File "/home/jross/mgmt/cumin/python/wooly/widgets.py", line 45, in render_mode
+ return mode.render(session, object)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 255, in render
+ string = self.do_render(session, object)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 265, in do_render
+ self.__main_tmpl.render(session, object, writer)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 791, in render
+ result = elem(self.widget, session, object)
+ File "/home/jross/mgmt/cumin/python/cumin/broker.py", line 616, in render_fields
+ self.field_tmpl.render(session, i, writer)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 791, in render
+ result = elem(self.widget, session, object)
+ File "/home/jross/mgmt/cumin/python/cumin/broker.py", line 643, in render_groups
+ self.group_tmpl.render(session, (index, group), writer)
+ File "/home/jross/mgmt/cumin/python/wooly/__init__.py", line 791, in render
+ result = elem(self.widget, session, object)
+ File "/home/jross/mgmt/cumin/python/cumin/broker.py", line 658, in render_group_selected_attr
+ if len(groups) > index and group.id == groups[index].id:
+AttributeError: 'NoneType' object has no attribute 'id'
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2008-01-11 17:43:52 UTC (rev 1553)
+++ mgmt/notes/justin-todo.txt 2008-01-12 22:35:40 UTC (rev 1554)
@@ -4,14 +4,8 @@
- Add javascript for the check-all behavior
- - "purge messages from queues"
-
* Improve charts
- - Add legends to charts
-
- - Display current values on right-side and according to color
-
- Add a "rate" mode to charts
* Mgmtd-broker interaction
@@ -34,6 +28,8 @@
* Div by zero error in queues view
+ * Make column sort disableable
+
Deferred
* Add "slowest views" tracking to --bench
More information about the rhmessaging-commits
mailing list