Author: justi9
Date: 2007-11-13 11:47:39 -0500 (Tue, 13 Nov 2007)
New Revision: 1298
Modified:
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokercluster.strings
mgmt/cumin/python/cumin/page.py
Log:
Adds cluster add and edit forms.
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2007-11-13 16:14:26 UTC (rev 1297)
+++ mgmt/cumin/python/cumin/brokercluster.py 2007-11-13 16:47:39 UTC (rev 1298)
@@ -12,10 +12,10 @@
strings = StringCatalog(__file__)
class BrokerClusterSet(ItemSet):
- def __init__(self, app, name):
- super(BrokerClusterSet, self).__init__(app, name)
-
- self.broker_tmpl = Template(self, "broker_html")
+ def render_cluster_add_href(self, session, model):
+ branch = session.branch()
+ self.page().show_broker_cluster_add(branch)
+ return branch.marshal()
def get_title(self, session, model):
return "Broker Clusters %s" \
@@ -53,6 +53,10 @@
self.add_mode(self.view)
self.set_view_mode(self.view)
+ self.edit = BrokerClusterEdit(app, "edit")
+ self.add_mode(self.edit)
+ self.set_edit_mode(self.edit)
+
self.broker = BrokerFrame(app, "broker")
self.add_mode(self.broker)
@@ -95,3 +99,49 @@
class ClusterStatsTab(Widget):
def get_title(self, session, cluster):
return "Statistics"
+
+class BrokerClusterForm(CuminForm):
+ def __init__(self, app, name):
+ super(BrokerClusterForm, self).__init__(app, name)
+
+ self.cluster_name = TextInput(app, "name", self)
+ self.add_child(self.cluster_name)
+
+ def process_cluster(self, session, cluster):
+ cluster.lock()
+ try:
+ cluster.name = self.cluster_name.get(session)
+ finally:
+ cluster.unlock()
+
+ branch = session.branch()
+ self.page().show_broker_cluster(branch, cluster).show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+class BrokerClusterAdd(BrokerClusterForm, Frame):
+ def get_title(self, session, model):
+ return "Add Cluster"
+
+ def process_cancel(self, session, model):
+ branch = session.branch()
+ self.page().show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, model):
+ cluster = BrokerCluster(model)
+ self.process_cluster(session, cluster)
+
+class BrokerClusterEdit(BrokerClusterForm, Frame):
+ def get_title(self, session, cluster):
+ return "Edit Cluster '%s'" % cluster.name
+
+ def process_cancel(self, session, cluster):
+ branch = session.branch()
+ self.parent.show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
+ def process_submit(self, session, cluster):
+ self.process_cluster(session, cluster)
+
+ def process_display(self, session, cluster):
+ self.cluster_name.set(session, cluster.name)
Modified: mgmt/cumin/python/cumin/brokercluster.strings
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.strings 2007-11-13 16:14:26 UTC (rev 1297)
+++ mgmt/cumin/python/cumin/brokercluster.strings 2007-11-13 16:47:39 UTC (rev 1298)
@@ -14,7 +14,7 @@
[BrokerClusterSet.html]
<ul class="actions">
- <li><a class="nav" href="{href}">Add Broker
Cluster</a></li>
+ <li><a class="nav" href="{cluster_add_href}">Add Broker
Cluster</a></li>
</ul>
<table class="mobjects">
@@ -84,3 +84,28 @@
<td>10 queues, 5 exchanges</td>
<td><a class="action"
href="">Remove</a></td>
</tr>
+
+[BrokerClusterForm.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>
+
+ {hidden_inputs}
+ </div>
+ <div class="foot">
+ <a class="help action" href="{href}"
target="help">Help</a>
+ {cancel}
+ {submit}
+ </div>
+</form>
+<script defer="defer">
+(function() {
+ var elem = wooly.doc().elembyid("{id}").node.elements[1];
+ elem.focus();
+ elem.select();
+}())
+</script>
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2007-11-13 16:14:26 UTC (rev 1297)
+++ mgmt/cumin/python/cumin/page.py 2007-11-13 16:47:39 UTC (rev 1298)
@@ -50,6 +50,9 @@
self.cluster = BrokerClusterFrame(app, "cluster")
self.add_mode(self.cluster)
+ self.cluster_add = BrokerClusterAdd(app, "clusteradd")
+ self.add_mode(self.cluster_add)
+
def save_session(self, session):
if self.app.debug:
self.app.debug.sessions.append(session)
@@ -110,6 +113,10 @@
frame.set_object(session, cluster)
return self.set_current_frame(session, frame)
+ def show_broker_cluster_add(self, session):
+ frame = self.show_mode(session, self.cluster_add)
+ return self.set_current_frame(session, frame)
+
def show_queue(self, session, queue):
broker = queue.get_virtual_host().get_broker()
frame = self.show_broker(session, broker)