Author: justi9
Date: 2007-10-12 11:44:10 -0400 (Fri, 12 Oct 2007)
New Revision: 1022
Modified:
mgmt/cumin/python/cumin/cluster.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/server.py
mgmt/cumin/python/cumin/virtualhost.py
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/wooly/__init__.py
Log:
Introduces a frame param on cuminpage. This is used to control when
state is preserved and when it is discarded. As it's currently
configured, the state you used to drill down to a specific object is
saved so that when you return tabs, etc., are as you left them.
Also removes render_hrefs from specific cumin frames and uses the
definition on CuminFrame.
Modified: mgmt/cumin/python/cumin/cluster.py
===================================================================
--- mgmt/cumin/python/cumin/cluster.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/cumin/cluster.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -71,11 +71,6 @@
self.vhost.set_virtual_host(session, vhost)
return self.show_mode(session, self.vhost)
- def render_href(self, session, cluster):
- branch = session.branch()
- self.page().show_cluster(branch, cluster).show_view(branch)
- return branch.marshal()
-
def render_title(self, session, cluster):
return "Cluster '%s'" % cluster.name
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/cumin/exchange.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -72,11 +72,6 @@
def show_view(self, session):
return self.show_mode(session, self.view)
- def render_href(self, session, exchange):
- branch = session.branch()
- self.show_view(branch)
- return branch.marshal()
-
def render_title(self, session, exchange):
return "Exchange '%s'" % exchange.name
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/cumin/page.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -17,6 +17,9 @@
self.frames = self.FramesAttribute(app, "frames")
self.add_attribute(self.frames)
+ self.frame = self.FrameParameter(app, "frame")
+ self.add_parameter(self.frame)
+
self.modal = Attribute(app, "modal")
self.add_attribute(self.modal)
@@ -30,6 +33,21 @@
def get_default(self, session):
return list()
+ class FrameParameter(Parameter):
+ def do_marshal(self, frame):
+ return frame.path()
+
+ def do_unmarshal(self, path):
+ return self.app.get_widget(path)
+
+ def set_frame(self, session, frame):
+ self.frame.set(session, frame)
+
+ return frame
+
+ def get_frame(self, session):
+ return self.frame.get(session)
+
def set_modal(self, session, modal):
self.modal.set(session, modal)
@@ -45,13 +63,15 @@
else:
frame = self.main.show_server(session, server)
- return frame
+ return self.set_frame(session, frame)
def show_server_group(self, session, sgroup):
- return self.main.show_server_group(session, sgroup)
+ frame = self.main.show_server_group(session, sgroup)
+ return self.set_frame(session, frame)
def show_cluster(self, session, cluster):
- return self.main.show_cluster(session, cluster)
+ frame = self.main.show_cluster(session, cluster)
+ return self.set_frame(session, frame)
def show_virtual_host(self, session, vhost):
server = vhost.get_server()
@@ -64,15 +84,18 @@
else:
frame = self.main
- return frame.show_virtual_host(session, vhost)
+ frame = frame.show_virtual_host(session, vhost)
+ return self.set_frame(session, frame)
def show_queue(self, session, queue):
frame = self.show_virtual_host(session, queue.virtual_host)
- return frame.show_queue(session, queue)
+ frame = frame.show_queue(session, queue)
+ return self.set_frame(session, frame)
def show_exchange(self, session, exchange):
frame = self.show_virtual_host(session, exchange.virtual_host)
- return frame.show_exchange(session, exchange)
+ frame = frame.show_exchange(session, exchange)
+ return self.set_frame(session, frame)
def render_title(self, session, object):
return "Cumin"
@@ -143,11 +166,6 @@
self.cluster.set_cluster(session, cluster)
return self.show_mode(session, self.cluster)
- def render_href(self, session, model):
- branch = session.branch()
- self.show_view(branch)
- return branch.marshal()
-
def render_title(self, session, model):
return "<img src=\"resource?name=logo.png\"/>"
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/cumin/queue.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -75,11 +75,6 @@
def show_view(self, session):
return self.show_mode(session, self.view)
- def render_href(self, session, queue):
- branch = session.branch()
- self.show_view(branch)
- return branch.marshal()
-
def render_title(self, session, queue):
return "Queue '%s'" % queue.name
Modified: mgmt/cumin/python/cumin/server.py
===================================================================
--- mgmt/cumin/python/cumin/server.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/cumin/server.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -69,11 +69,6 @@
vhost = self.show_virtual_host(session, exchange.virtual_host)
return vhost.show_exchange(session, exchange)
- def render_href(self, session, server):
- branch = session.branch()
- self.show_mode(branch, self.view)
- return branch.marshal()
-
def render_title(self, session, server):
return "Server '%s'" % server.name
Modified: mgmt/cumin/python/cumin/virtualhost.py
===================================================================
--- mgmt/cumin/python/cumin/virtualhost.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/cumin/virtualhost.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -60,11 +60,6 @@
return self.show_mode(session, self.exchange)
- def render_href(self, session, vhost):
- branch = session.branch()
- self.show_view(branch)
- return branch.marshal()
-
class VirtualHostFrame(BaseVirtualHostFrame):
def __init__(self, app, name):
super(VirtualHostFrame, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/cumin/widgets.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -15,11 +15,26 @@
return "<span class=\"none\">None</span>"
class CuminFrame(Frame, ModeSet):
+ def save_parameters(self, session):
+ frame = self.page().get_frame(session)
+
+ if not frame or self is frame or self in frame.ancestors():
+ super(CuminFrame, self).save_parameters(session)
+
def do_process(self, session, object):
self.page().get_frames(session).append(self)
super(CuminFrame, self).do_process(session, object)
+ def show_view(self, session):
+ pass
+
+ def render_href(self, session, vhost):
+ branch = session.branch()
+ self.page().set_frame(branch, self)
+ self.show_view(branch)
+ return branch.marshal()
+
class CuminForm(Form):
def __init__(self, app, name):
super(CuminForm, self).__init__(app, name)
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2007-10-12 15:08:10 UTC (rev 1021)
+++ mgmt/cumin/python/wooly/__init__.py 2007-10-12 15:44:10 UTC (rev 1022)
@@ -19,6 +19,7 @@
self.parameters = list()
self.template = Template(self, "html")
+ self.cached_ancestors = None
self.cached_path = None
self.cached_page = None
self.child_index = None
@@ -27,6 +28,17 @@
self.strings = None
+ def ancestors(self):
+ if not self.cached_ancestors:
+ if not self.parent:
+ self.cached_ancestors = tuple()
+ else:
+ ancs = list(self.parent.ancestors())
+ ancs.append(self)
+ self.cached_ancestors = tuple(ancs)
+
+ return self.cached_ancestors
+
def path(self):
if not self.cached_path:
if not self.parent: