Author: justi9
Date: 2007-11-06 14:33:34 -0500 (Tue, 06 Nov 2007)
New Revision: 1255
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/wooly/__init__.py
mgmt/cumin/python/wooly/server.py
mgmt/notes/justin-todo.txt
Log:
Adds a page attribute for redirects, instead of having a field
directly on session.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-06 19:08:39 UTC (rev 1254)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-06 19:33:34 UTC (rev 1255)
@@ -84,7 +84,7 @@
for broker in self.brokers.get(session):
print "broker", broker
- session.set_redirect(session.marshal())
+ self.page().set_redirect_url(session, session.marshal())
def render_item_checkbox_name(self, session, broker):
return self.brokers.path()
@@ -189,7 +189,7 @@
def process_cancel(self, session, prop):
branch = session.branch()
self.page().show_broker(branch, prop.get_broker()).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, prop):
source = self.source.get(session)
@@ -513,7 +513,7 @@
def process_cancel(self, session, model):
branch = session.branch()
self.page().show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
names = self.names.get(session)
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2007-11-06 19:08:39 UTC (rev 1254)
+++ mgmt/cumin/python/cumin/brokergroup.py 2007-11-06 19:33:34 UTC (rev 1255)
@@ -114,13 +114,13 @@
branch = session.branch()
self.page().show_broker_group(branch, group).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
class BrokerGroupAdd(BrokerGroupForm, Frame):
def process_cancel(self, session, model):
branch = session.branch()
self.page().show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
group = BrokerGroup(model)
@@ -133,7 +133,7 @@
def process_cancel(self, session, group):
branch = session.branch()
self.parent.show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, group):
self.process_group(session, group)
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-11-06 19:08:39 UTC (rev 1254)
+++ mgmt/cumin/python/cumin/exchange.py 2007-11-06 19:33:34 UTC (rev 1255)
@@ -238,7 +238,7 @@
def process_cancel(self, session, vhost):
branch = session.branch()
self.page().show_broker(branch, vhost.get_broker()).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, vhost):
if self.validate(session):
@@ -255,7 +255,7 @@
branch = session.branch()
self.page().show_exchange(branch, exchange).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def render_title(self, session, vhost):
return "Add Exchange to Host Template '%s'" % vhost.name
@@ -264,7 +264,7 @@
def process_cancel(self, session, exchange):
branch = session.branch()
self.page().show_exchange(branch, exchange).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, exchange):
if self.validate(session):
@@ -275,9 +275,7 @@
finally:
exchange.unlock()
- branch = session.branch()
- self.page().show_exchange(branch, exchange).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.process_cancel(session, exchange)
def process_display(self, session, exchange):
self.exchange_name.set(session, exchange.name)
@@ -287,6 +285,11 @@
return "Edit Exchange '%s'" % exchange.name
class ExchangeRemove(CuminConfirmForm):
+ def process_cancel(self, session, exchange):
+ branch = session.branch()
+ self.page().show_exchange(branch, exchange).show_view(branch)
+ session.set_redirect(branch.marshal())
+
def process_submit(self, session, exchange):
vhost = exchange.get_virtual_host()
@@ -294,13 +297,8 @@
branch = session.branch()
self.page().show_broker(branch, vhost.get_broker()).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
- def process_cancel(self, session, exchange):
- branch = session.branch()
- self.page().show_exchange(branch, exchange).show_view(branch)
- session.set_redirect(branch.marshal())
-
def render_title(self, session, exchange):
return "Remove Exchange '%s'" % exchange.name
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-06 19:08:39 UTC (rev 1254)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-06 19:33:34 UTC (rev 1255)
@@ -260,7 +260,7 @@
def process_cancel(self, session, vhost):
branch = session.branch()
self.page().show_broker(branch, vhost.get_broker()).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, vhost):
if self.validate(session):
@@ -277,7 +277,7 @@
branch = session.branch()
self.page().show_queue(branch, queue).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def render_title(self, session, vhost):
return "Add Queue to Host Template '%s'" % vhost.name
@@ -286,7 +286,7 @@
def process_cancel(self, session, queue):
branch = session.branch()
self.page().show_queue(branch, queue).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, queue):
if self.validate(session):
@@ -299,7 +299,7 @@
branch = session.branch()
self.page().show_queue(branch, queue).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.process_cancel(session, queue)
def process_display(self, session, queue):
self.queue_name.set(session, queue.name)
@@ -309,6 +309,11 @@
return "Edit Queue '%s'" % queue.name
class QueueRemove(CuminConfirmForm):
+ def process_cancel(self, session, queue):
+ branch = session.branch()
+ self.page().show_queue(branch, queue).show_view(branch)
+ self.page().set_redirect_url(session, branch.marshal())
+
def process_submit(self, session, queue):
vhost = queue.get_virtual_host()
@@ -316,13 +321,8 @@
branch = session.branch()
self.page().show_broker(branch, vhost.get_broker()).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
- def process_cancel(self, session, queue):
- branch = session.branch()
- self.page().show_queue(branch, queue).show_view(branch)
- session.set_redirect(branch.marshal())
-
def render_title(self, session, queue):
return "Remove Queue '%s'" % queue.name
@@ -348,7 +348,7 @@
def process_cancel(self, session, queue):
branch = session.branch()
self.page().show_queue(branch, queue).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
def validate(self, session):
valid = True
@@ -379,25 +379,23 @@
finally:
binding.unlock()
- branch = session.branch()
- self.page().show_queue(branch, queue).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.process_cancel(session, queue)
class Exchanges(ExchangeInputSet):
def get_items(self, session, queue):
return sorted_by(queue.virtual_host.exchange_items())
class QueueBindingRemove(CuminConfirmForm):
- 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())
-
def process_cancel(self, session, binding):
branch = session.branch()
self.page().show_queue(branch, binding.get_queue()).show_view(branch)
- session.set_redirect(branch.marshal())
+ self.page().set_redirect_url(session, branch.marshal())
+ def process_submit(self, session, binding):
+ print binding
+
+ self.process_cancel(session, binding)
+
def render_title(self, session, binding):
return "Remove Binding"
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2007-11-06 19:08:39 UTC (rev 1254)
+++ mgmt/cumin/python/wooly/__init__.py 2007-11-06 19:33:34 UTC (rev 1255)
@@ -268,6 +268,9 @@
def __init__(self, app, name):
super(Page, self).__init__(app, name)
+ self.redirect = Attribute(app, "redirect")
+ self.add_attribute(self.redirect)
+
self.frame = self.FrameParameter(app, "frame")
self.add_parameter(self.frame)
self.set_default_frame(self)
@@ -283,6 +286,14 @@
def save_session(self, session):
pass
+ def set_redirect_url(self, session, url):
+ self.redirect.set(session, url)
+
+ return url
+
+ def get_redirect_url(self, session):
+ return self.redirect.get(session)
+
def set_current_frame(self, session, frame):
self.frame.set(session, frame)
@@ -422,7 +433,6 @@
self.page = None
self.values = dict()
self.errors = dict() # widget => list of str
- self.redirect = None
self.saved_parameters = list()
if self.app.debug:
@@ -493,9 +503,6 @@
errors.append(error)
- def set_redirect(self, redirect):
- self.redirect = redirect
-
def marshal(self):
page = self.marshal_page()
vars = self.marshal_url_vars()
Modified: mgmt/cumin/python/wooly/server.py
===================================================================
--- mgmt/cumin/python/wooly/server.py 2007-11-06 19:08:39 UTC (rev 1254)
+++ mgmt/cumin/python/wooly/server.py 2007-11-06 19:33:34 UTC (rev 1255)
@@ -58,9 +58,11 @@
self.error(session)
return
- if session.redirect:
+ redirect = page.get_redirect_url(session)
+
+ if redirect:
self.send_response(303)
- self.send_header("Location", session.redirect)
+ self.send_header("Location", redirect)
self.end_headers()
return
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-11-06 19:08:39 UTC (rev 1254)
+++ mgmt/notes/justin-todo.txt 2007-11-06 19:33:34 UTC (rev 1255)
@@ -2,7 +2,7 @@
* Add ability to send a test message to a queue
- * Use page attributes for session errors, redirect
+ * Use page attributes for session errors
* Queue: Add a msg enq rate msg deq rate chart