Author: justi9
Date: 2007-10-17 09:27:03 -0400 (Wed, 17 Oct 2007)
New Revision: 1100
Modified:
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/widgets.py
Log:
Consolidates form processing logic into CuminForm.
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-10-17 13:13:23 UTC (rev 1099)
+++ mgmt/cumin/python/cumin/exchange.py 2007-10-17 13:27:03 UTC (rev 1100)
@@ -219,7 +219,7 @@
return "Edit Exchange '%s'" % exchange.name
class ExchangeRemove(CuminConfirmForm):
- def process_confirm(self, session, exchange):
+ def process_submit(self, session, exchange):
vhost = exchange.get_virtual_host()
exchange.remove()
@@ -236,7 +236,7 @@
def render_title(self, session, exchange):
return "Remove Exchange '%s'" % exchange.name
- def render_confirm_content(self, session, exchange):
+ def render_submit_content(self, session, exchange):
return "Yes, Remove Exchange '%s'" % exchange.name
def render_cancel_content(self, session, exchange):
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-10-17 13:13:23 UTC (rev 1099)
+++ mgmt/cumin/python/cumin/queue.py 2007-10-17 13:27:03 UTC (rev 1100)
@@ -253,7 +253,7 @@
return "Edit Queue '%s'" % queue.name
class QueueRemove(CuminConfirmForm):
- def process_confirm(self, session, queue):
+ def process_submit(self, session, queue):
vhost = queue.get_virtual_host()
queue.remove()
@@ -270,7 +270,7 @@
def render_title(self, session, queue):
return "Remove Queue '%s'" % queue.name
- def render_confirm_content(self, session, queue):
+ def render_submit_content(self, session, queue):
return "Yes, Remove Queue '%s'" % queue.name
def render_cancel_content(self, session, queue):
@@ -332,7 +332,7 @@
return sorted_by(queue.virtual_host.exchange_items())
class QueueBindingRemove(CuminConfirmForm):
- def process_confirm(self, session, binding):
+ def process_submit(self, session, binding):
branch = session.branch()
self.page().show_queue(branch, binding.get_queue()).show_view(branch)
session.set_redirect(branch.marshal())
@@ -345,7 +345,7 @@
def render_title(self, session, binding):
return "Remove Binding"
- def render_confirm_content(self, session, binding):
+ def render_submit_content(self, session, binding):
return "Yes, Remove Binding"
def render_cancel_content(self, session, binding):
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-10-17 13:13:23 UTC (rev 1099)
+++ mgmt/cumin/python/cumin/widgets.py 2007-10-17 13:27:03 UTC (rev 1100)
@@ -78,58 +78,20 @@
def process_display(self, session, object):
pass
+ def render_cancel_content(self, session, object):
+ return "Cancel"
+
+ def render_submit_content(self, session, object):
+ return "Submit"
+
class Cancel(FormButton):
def render_content(self, session, object):
- return "Cancel"
+ return self.parent.render_cancel_content(session, object)
class Submit(FormButton):
def render_content(self, session, object):
- return "Submit"
-
-class CuminConfirmForm(Form):
+ return self.parent.render_submit_content(session, object)
+
+class CuminConfirmForm(CuminForm):
def __init__(self, app, name):
super(CuminConfirmForm, self).__init__(app, name)
-
- self.confirm = self.ConfirmButton(app, "confirm", self)
- self.confirm.set_tab_index(101)
- self.add_child(self.confirm)
-
- self.cancel = self.CancelButton(app, "cancel", self)
- self.add_child(self.cancel)
-
- def do_process(self, session, object):
- self.page().set_modal(session, True)
-
- if self.confirm.get(session):
- self.confirm.set(session, False)
-
- self.process_confirm(session, object)
- elif self.cancel.get(session):
- self.cancel.set(session, False)
-
- self.process_cancel(session, object)
- else:
- self.process_display(session, object)
-
- def process_cancel(self, session, object):
- pass
-
- def process_confirm(self, session, object):
- pass
-
- def process_display(self, session, object):
- pass
-
- def render_confirm_content(self, session, object):
- return "Confirm"
-
- def render_cancel_content(self, session, object):
- return "Cancel"
-
- class ConfirmButton(FormButton):
- def render_content(self, session, object):
- return self.parent.render_confirm_content(session, object)
-
- class CancelButton(FormButton):
- def render_content(self, session, object):
- return self.parent.render_cancel_content(session, object)