[rhmessaging-commits] rhmessaging commits: r1719 - in mgmt: notes and 1 other directory.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Thu Feb 21 13:53:14 EST 2008
Author: justi9
Date: 2008-02-21 13:53:14 -0500 (Thu, 21 Feb 2008)
New Revision: 1719
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/broker.strings
mgmt/cumin/python/cumin/brokergroup.py
mgmt/notes/justin-todo.txt
Log:
Adds a form to edit broker registrations names and group membership.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-02-21 18:52:49 UTC (rev 1718)
+++ mgmt/cumin/python/cumin/broker.py 2008-02-21 18:53:14 UTC (rev 1719)
@@ -135,6 +135,10 @@
self.add_mode(self.view)
self.set_view_mode(self.view)
+ self.edit = BrokerEdit(app, "edit")
+ self.add_mode(self.edit)
+ self.set_edit_mode(self.edit)
+
self.remove = BrokerRemove(app, "remove")
self.add_mode(self.remove)
self.set_remove_mode(self.remove)
@@ -659,6 +663,82 @@
self.process_cancel(session, model)
+# XXX I would like to move this to brokergroup.py, once I fix the
+# python import issues
+class BrokerGroupInputSet(CheckboxInputSet):
+ def __init__(self, app, name, form):
+ super(BrokerGroupInputSet, self).__init__(app, name, form)
+
+ param = ListParameter(app, "param", BrokerGroupParameter(app, "item"))
+ self.add_parameter(param)
+ self.set_parameter(param)
+
+ def do_get_items(self, session, model):
+ return BrokerGroup.select()
+
+ def render_item_value(self, session, group):
+ return group.id
+
+ def render_item_content(self, session, group):
+ return group.name
+
+ def render_item_checked_attr(self, session, group):
+ return group in self.param.get(session) and "checked=\"checked\""
+
+class BrokerEdit(CuminForm, Frame):
+ def __init__(self, app, name):
+ super(BrokerEdit, self).__init__(app, name)
+
+ self.broker_name = TextInput(app, "name", self)
+ self.add_child(self.broker_name)
+
+ self.groups = BrokerGroupInputSet(app, "groups", self)
+ self.add_child(self.groups)
+
+ def get_title(self, session, reg):
+ return "Edit Broker '%s'" % reg.name
+
+ def validate(self, session):
+ error = None
+
+ name = self.broker_name.get(session)
+
+ if name == "":
+ error = EmptyInputError(self.broker_name)
+ self.broker_name.add_error(session, error)
+
+ return error is None
+
+ def process_cancel(self, session, reg):
+ branch = session.branch()
+ self.frame().show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, reg):
+ if self.validate(session):
+ action = self.app.model.broker_registration.edit
+ args = {"name": self.broker_name.get(session)}
+ action.invoke(reg, args)
+
+ for group in self.groups.get(session):
+ if group not in reg.groups:
+ reg.addBrokerGroup(group)
+
+ for group in reg.groups:
+ if group not in self.groups.get(session):
+ reg.removeBrokerGroup(group)
+
+ reg.syncUpdate()
+
+ self.process_cancel(session, reg)
+
+ def process_display(self, session, reg):
+ self.broker_name.set(session, reg.name)
+
+ for group in reg.groups:
+ self.groups.get(session).append(group)
+
+# XXX use reg, not broker, where appropriate
class BrokerRemove(CuminConfirmForm):
def get_title(self, session, broker):
return "Unregister Broker '%s'" % broker.name
Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings 2008-02-21 18:52:49 UTC (rev 1718)
+++ mgmt/cumin/python/cumin/broker.strings 2008-02-21 18:53:14 UTC (rev 1719)
@@ -142,6 +142,7 @@
<tr>
<th class="actions" colspan="2">
<h2>Act on This Broker:</h2>
+ <a class="nav" href="{edit_href}">Edit</a>
<a href="{remove_href}">Unregister</a>
</th>
</tr>
@@ -201,19 +202,19 @@
[BrokerBrowser.cluster_html]
<li>{cluster_link}</li>
-[BrokerForm.css]
-table.BrokerForm td, table.BrokerForm th {
+[BrokerSetForm.css]
+table.BrokerSetForm td, table.BrokerSetForm th {
padding: 0.25em;
}
-[BrokerForm.html]
+[BrokerSetForm.html]
<form id="{id}" class="mform" method="post" action="?">
<div class="head">
<h1>{title}</h1>
</div>
<div class="body">
<fieldset>
- <table class="BrokerForm">
+ <table class="BrokerSetForm">
<tr>
<th>Name</th>
<th>Host Name or IP Address</th>
@@ -242,7 +243,7 @@
}())
</script>
-[BrokerForm.field_html]
+[BrokerSetForm.field_html]
<tr>
<td><input type="text" name="{field_name_name}" value="{field_name_value}" size="15" tabindex="100"/></td>
<td><input type="text" name="{field_address_name}" value="{field_address_value}" size="35" tabindex="100"/></td>
@@ -254,5 +255,39 @@
</td>
</tr>
-[BrokerForm.group_html]
+[BrokerSetForm.group_html]
<option value="{group_value}" {group_selected_attr}>{group_name}</option>
+
+[BrokerEdit.html]
+<form id="{id}" class="mform" method="post" action="?">
+ <div class="head">
+ <h1>{title}</h1>
+ </div>
+ <div class="body">
+ <span class="legend">Name</span>
+ <fieldset>{name}</fieldset>
+
+ <span class="legend">Groups</span>
+ <fieldset>{groups}</fieldset>
+
+ {hidden_inputs}
+ </div>
+ <div class="foot">
+ <a class="help action" href="{href}" target="help">Help</a>
+ {submit}
+ {cancel}
+ </div>
+</form>
+<script defer="defer">
+(function() {
+ var elem = wooly.doc().elembyid("{id}").node.elements[1];
+ elem.focus();
+ elem.select();
+}())
+</script>
+
+[BrokerGroupInputSet.item_html]
+<div class="field">
+ <input type="checkbox" name="{name}" value="{item_value}" tabindex="{tab_index}" {item_checked_attr}/>
+ {item_content}
+</div>
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-02-21 18:52:49 UTC (rev 1718)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-02-21 18:53:14 UTC (rev 1719)
@@ -1,6 +1,7 @@
from mint import *
from wooly import *
from wooly.widgets import *
+from wooly.forms import *
from broker import BrokerSet
from widgets import *
@@ -38,6 +39,26 @@
self.app.model.broker_group.show(branch, group).show_view(branch)
return fmt_olink(branch, group, name=data["name"])
+class BrokerGroupInputSet(CheckboxInputSet):
+ def __init__(self, app, name, form):
+ super(BrokerGroupInputSet, self).__init__(app, name, form)
+
+ param = ListParameter(app, "param", BrokerGroupParameter(app, "item"))
+ self.add_parameter(param)
+ self.set_parameter(param)
+
+ def do_get_items(self, session, model):
+ return BrokerGroup.select()
+
+ def render_item_value(self, session, group):
+ return group.id
+
+ def render_item_content(self, session, group):
+ return group.name
+
+ def render_item_checked_attr(self, session, group):
+ return group in self.param.get(session) and "checked=\"checked\""
+
class BrokerGroupFrame(CuminFrame):
def __init__(self, app, name):
super(BrokerGroupFrame, self).__init__(app, name)
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2008-02-21 18:52:49 UTC (rev 1718)
+++ mgmt/notes/justin-todo.txt 2008-02-21 18:53:14 UTC (rev 1719)
@@ -12,16 +12,18 @@
* Get rid of single object confirms
- * No way to ungroupify a broker
-
- * No broker edit form
-
* Add examples of legit broker addresses in broker add form
- * Validate broker and group names in forms
+ * Add broker reg name unique constraint and validation
Deferred
+ * See if we can't avoid the app.add_parameter in Parameter; adding to
+ page somehow would make a lot more sense
+
+ * In validate methods, instead of using an error var, add an error to
+ the form indicating that the form has member widgets with errors.
+
* Unregistering a broker doesn't disconnect it
* Don't let anyone close mgmt clients
@@ -74,24 +76,8 @@
* Indicate how old stats are
- * Add broker reg name unique constraint and validation
-
- * Whereever it makes sense, add a switch to display living, dead, or
- all objects
-
- * BrokerSetForm displays no rows instead of [None] with some filters
-
- * Add an edit form for broker registrations so you can change their
- names, and also their group membership
-
* Add inactive state to some status lights
- * Paginate producers
-
- * Paginate consumers
-
- * Email amqp-list, Jonathan, and Lana with doc requirements for mgmt
-
* Ask tross to take some prints out of ManagedBroker.start
* Add a do_get_item_count, and cache result for use by get_item_count
@@ -115,8 +101,6 @@
* Restore high-low
- * Fix sqlobject init: make it happen at cumin init
-
* "remove broker groups"
* "shutdown broker groups"
@@ -130,14 +114,10 @@
* Add a wooly.focus(id) method to replace the ad-hoc javascript I'm
using
- * The granularity of radio and checkbox disabling seems to be off
-
* Make the status lights also be links to an appropriate view
- Defer until we know what we're going to link to
- * Add a CuminItemSet with add/edit/remove href parts
-
* Add a parameter that takes a modelclass
* Make it a little simpler to express hrefs
@@ -146,8 +126,6 @@
* Add an error banner to form
- * Use wsgiref instead of BaseHTTPServer
-
* Separate wooly stuff into its own devel subdir
* Consider having a cssclass set on widgets
More information about the rhmessaging-commits
mailing list