Author: justi9
Date: 2007-11-07 12:19:21 -0500 (Wed, 07 Nov 2007)
New Revision: 1261
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/broker.strings
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/wooly/forms.py
mgmt/cumin/python/wooly/forms.strings
mgmt/notes/justin-todo.txt
Log:
Adds an initial group drop-down to the broker registration form.
Adds a reusable option input widget to the form widgets.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-07 16:11:13 UTC (rev 1260)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-07 17:19:21 UTC (rev 1261)
@@ -468,11 +468,20 @@
self.add_parameter(self.addrs)
self.add_form_parameter(self.addrs)
+ self.group_param = BrokerGroupParameter(app, "group_param")
+ self.add_parameter(self.group_param)
+ self.add_form_parameter(self.group_param)
+
+ self.groups = ListParameter(app, "group", self.group_param)
+ self.add_parameter(self.groups)
+ self.add_form_parameter(self.groups)
+
self.fields = IntegerParameter(app, "fields")
self.fields.set_default(3)
self.add_parameter(self.fields)
self.field_tmpl = Template(self, "field_html")
+ self.group_tmpl = Template(self, "group_html")
self.more = self.MoreEntries(app, "more", self)
self.add_child(self.more)
@@ -500,11 +509,36 @@
def render_field_address_name(self, session, object):
return self.addrs.path()
+ def render_field_group_name(self, session, object):
+ return self.groups.path()
+
def render_field_address_value(self, session, index):
addrs = self.addrs.get(session)
if len(addrs) > index:
return addrs[index]
-
+
+ def render_groups(self, session, index):
+ writer = Writer()
+
+ for group in self.app.model.get_broker_groups():
+ self.group_tmpl.render(session, (index, group), writer)
+
+ return writer.to_string()
+
+ def render_group_value(self, session, args):
+ index, group = args
+ return group.id
+
+ def render_group_name(self, session, args):
+ index, group = args
+ return group.name
+
+ def render_group_selected_attr(self, session, args):
+ index, group = args
+ groups = self.groups.get(session)
+ if len(groups) > index and group.id == groups[index].id:
+ return "selected=\"selected\""
+
class MoreEntries(FormButton):
def render_content(self, session, model):
return "More Entries"
@@ -518,9 +552,10 @@
def process_submit(self, session, model):
names = self.names.get(session)
addrs = self.addrs.get(session)
+ groups = self.groups.get(session)
- for name, addr in zip(names, addrs):
- print name, addr
+ for name, addr, group in zip(names, addrs, groups):
+ print name, addr, group
self.process_cancel(session, model)
Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings 2007-11-07 16:11:13 UTC (rev 1260)
+++ mgmt/cumin/python/cumin/broker.strings 2007-11-07 17:19:21 UTC (rev 1261)
@@ -212,7 +212,8 @@
<table class="BrokerForm">
<tr>
<th>Name</th>
- <th>Address</th>
+ <th>Host Name or IP Address</th>
+ <th>Initial Group</th>
</tr>
{fields}
@@ -239,6 +240,10 @@
[BrokerForm.field_html]
<tr>
- <td><input type="text" name="{field_name_name}"
value="{field_name_value}" size="20"
tabindex="100"/></td>
- <td><input type="text" name="{field_address_name}"
value="{field_address_value}" size="40"
tabindex="100"/></td>
+ <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>
+ <td><select name="{field_group_name}"
tabindex="100">{groups}</select></td>
</tr>
+
+[BrokerForm.group_html]
+<option value="{group_value}"
{group_selected_attr}>{group_name}</option>
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2007-11-07 16:11:13 UTC (rev 1260)
+++ mgmt/cumin/python/cumin/brokergroup.py 2007-11-07 17:19:21 UTC (rev 1261)
@@ -143,3 +143,13 @@
def render_title(self, session, group):
return "Edit Group '%s'" % group.name
+
+class BrokerGroupInput(OptionInputSet):
+ def get_items(self, session, model):
+ return model.get_broker_groups()
+
+ def render_item_value(self, session, group):
+ return group.id
+
+ def render_item_selected_attr(self, session, group):
+ return None
Modified: mgmt/cumin/python/wooly/forms.py
===================================================================
--- mgmt/cumin/python/wooly/forms.py 2007-11-07 16:11:13 UTC (rev 1260)
+++ mgmt/cumin/python/wooly/forms.py 2007-11-07 17:19:21 UTC (rev 1261)
@@ -205,9 +205,6 @@
return super(FormButton, self).render_value(branch, object)
class CheckboxInputSet(FormInput, ItemSet):
- def __init__(self, app, name, form):
- super(CheckboxInputSet, self).__init__(app, name, form)
-
def render_item_value(self, session, object):
return None
@@ -220,3 +217,10 @@
def render_item_checked_attr(self, session, object):
return None
+
+class OptionInputSet(FormInput, ItemSet):
+ def render_item_value(self, session, object):
+ return None
+
+ def render_item_selected_attr(self, session, object):
+ return None
Modified: mgmt/cumin/python/wooly/forms.strings
===================================================================
--- mgmt/cumin/python/wooly/forms.strings 2007-11-07 16:11:13 UTC (rev 1260)
+++ mgmt/cumin/python/wooly/forms.strings 2007-11-07 17:19:21 UTC (rev 1261)
@@ -30,3 +30,10 @@
[RadioInputSet.item_html]
<input type="radio" name="{name}" value="{item_value}"
tabindex="{tab_index}" {item_checked_attr} {disabled_attr}/>
{item_content}
+
+[OptionInputSet.html]
+{errors}
+<select name="{name}" tabindex="{tab_index}"
{disabled_attr}>{items}</select>
+
+[OptionInputSet.item_html]
+<option value="{item_value}" tabindex="{tab_index}"
{item_selected_attr} {disabled_attr}>{item_content}</option>
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-11-07 16:11:13 UTC (rev 1260)
+++ mgmt/notes/justin-todo.txt 2007-11-07 17:19:21 UTC (rev 1261)
@@ -13,8 +13,6 @@
in the render_title calls. Perhaps introduce a get_title to solve
this.
- * Add initial group drop down to broker add form
-
* Add totals to client msgs produced
* Add rolled up stats for objs other than queues
@@ -25,8 +23,12 @@
* Ajaxify charts
+ * Add a none option to the inital group select in broker register
+
Deferred
+ * The granularity of radio and checkbox disabling seems to be off
+
* Rename Widget.name to .__name
* Make the status lights also be links to an appropriate view