Author: justi9
Date: 2008-02-04 12:55:54 -0500 (Mon, 04 Feb 2008)
New Revision: 1639
Modified:
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokerprofile.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/page.strings
Log:
Rationalizes top-level navigation.
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2008-02-04 17:55:32 UTC (rev 1638)
+++ mgmt/cumin/python/cumin/brokercluster.py 2008-02-04 17:55:54 UTC (rev 1639)
@@ -123,7 +123,7 @@
def process_cancel(self, session, model):
branch = session.branch()
- self.page().show_view(branch)
+ self.page().show_main(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
@@ -158,7 +158,7 @@
cluster.destroySelf()
branch = session.branch()
- self.page().show_view(branch)
+ self.page().show_main(branch)
self.page().set_redirect_url(session, branch.marshal())
def render_submit_content(self, session, cluster):
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-02-04 17:55:32 UTC (rev 1638)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-02-04 17:55:54 UTC (rev 1639)
@@ -159,7 +159,7 @@
method.invoke(group)
branch = session.branch()
- self.page().show_view(branch).show_messaging(branch)
+ self.page().show_main(branch)
self.page().set_redirect_url(session, branch.marshal())
def render_submit_content(self, session, group):
Modified: mgmt/cumin/python/cumin/brokerprofile.py
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.py 2008-02-04 17:55:32 UTC (rev 1638)
+++ mgmt/cumin/python/cumin/brokerprofile.py 2008-02-04 17:55:54 UTC (rev 1639)
@@ -124,7 +124,7 @@
def process_cancel(self, session, model):
branch = session.branch()
- self.page().show_view(branch)
+ self.page().show_main(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, model):
@@ -159,7 +159,7 @@
profile.destroySelf()
branch = session.branch()
- self.page().show_view(branch)
+ self.page().show_main(branch)
self.page().set_redirect_url(session, branch.marshal())
def render_submit_content(self, session, profile):
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2008-02-04 17:55:32 UTC (rev 1638)
+++ mgmt/cumin/python/cumin/model.py 2008-02-04 17:55:54 UTC (rev 1639)
@@ -330,8 +330,8 @@
super(CuminBroker, self).__init__(model, "broker", Broker,
BrokerStats)
def show(self, session, broker):
- frame = self.model.app.main_page.show_view(session)
- return frame.show_messaging(session).show_broker(session, broker)
+ frame = self.model.app.main_page.show_main(session)
+ return frame.show_broker(session, broker)
class CuminQueue(CuminClass):
def __init__(self, model):
@@ -691,8 +691,8 @@
(model, "broker_group", BrokerGroup, None)
def show(self, session, group):
- frame = self.model.app.main_page.show_view(session)
- return frame.show_messaging(session).show_broker_group(session, group)
+ frame = self.model.app.main_page.show_main(session)
+ return frame.show_broker_group(session, group)
def get_title(self, session):
return "Broker Group"
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-02-04 17:55:32 UTC (rev 1638)
+++ mgmt/cumin/python/cumin/page.py 2008-02-04 17:55:54 UTC (rev 1639)
@@ -23,16 +23,14 @@
self.__modal = Attribute(app, "modal")
self.add_attribute(self.__modal)
- self.__view = MainView(app, "main")
- self.add_mode(self.__view)
+ self.__main = MainFrame(app, "main")
+ self.add_mode(self.__main)
+ self.set_default_frame(self.__main)
- def show_view(self, session):
- return self.show_mode(session, self.__view)
+ def show_main(self, session):
+ frame = self.show_mode(session, self.__main)
+ return self.set_current_frame(session, frame)
- def show_broker(self, session, broker):
- frame = self.show_view(session).show_messaging(session)
- return frame.show_broker(session, broker)
-
def save_session(self, session):
if self.app.debug:
self.app.debug.sessions.append(session)
@@ -50,78 +48,38 @@
def get_frames(self, session):
return self.__frames.get(session)
- def do_process(self, session, model):
- super(CuminPage, self).do_process(session, model)
-
- if self.get_current_frame(session) is self:
- self.show_view(session).show_messaging(session)
-
def render_class(self, session, object):
return self.__modal.get(session) and "modal"
def get_title(self, session, model):
return "MRG Management"
-class MainView(TabSet):
+class MainFrame(CuminFrame):
def __init__(self, app, name):
- super(MainView, self).__init__(app, name)
+ super(MainFrame, self).__init__(app, name)
+ self.__tab_tmpl = Template(self, "tab_html")
self.__frame_tmpl = Template(self, "frame_html")
- self.__object = Attribute(app, "object")
- self.add_attribute(self.__object)
+ self.__tabs = list()
- self.__messaging = MessagingFrame(app, "msg")
- self.add_tab(self.__messaging)
- self.add_tab(GridFrame(app, "grd"))
- self.add_tab(SystemsFrame(app, "sys"))
+ tab = self.MessagingTab(app, "mtab")
+ self.add_child(tab)
+ self.__tabs.append(tab)
- def show_messaging(self, session):
- frame = self.show_mode(session, self.__messaging)
- return self.page().set_current_frame(session, frame)
+ tab = self.GridTab(app, "gtab")
+ self.add_child(tab)
+ self.__tabs.append(tab)
- def render_tab_href(self, session, mode):
- branch = session.branch()
- self.set_selected_mode(branch, mode)
+ tab = self.SystemsTab(app, "stab")
+ self.add_child(tab)
+ self.__tabs.append(tab)
- if mode not in self.page().get_current_frame(branch).ancestors():
- self.page().set_current_frame(branch, mode)
+ # XXX get rid of this
+ self.__object = Attribute(app, "object")
+ self.add_attribute(self.__object)
- return branch.marshal()
-
- def render_frames(self, session, object):
- self.__object.set(session, object)
- writer = Writer()
-
- for frame in self.page().get_frames(session):
- self.__frame_tmpl.render(session, frame, writer)
-
- return writer.to_string()
-
- def render_frame_href(self, session, frame):
- object = frame.get_object(session, self.__object.get(session))
- return frame.render_href(session, object)
-
- def render_frame_title(self, session, frame):
- object = frame.get_object(session, self.__object.get(session))
- return frame.render_title(session, object)
-
- def render_pending_count(self, session, object):
- return self.app.model.count_invocations("pending")
-
- def render_completed_count(self, session, object):
- return self.app.model.count_invocations("OK")
-
- def render_failed_count(self, session, object):
- pcount = self.app.model.count_invocations("pending")
- ccount = self.app.model.count_invocations("OK")
- return len(self.app.model.invocations) - pcount - ccount
-
-class MessagingFrame(CuminFrame):
- def __init__(self, app, name):
- super(MessagingFrame, self).__init__(app, name)
-
- self.__view = MessagingView(app, "view")
+ self.__view = MainView(app, "view")
self.add_mode(self.__view)
self.set_view_mode(self.__view)
@@ -153,9 +111,83 @@
self.__cluster_add = BrokerClusterAdd(app, "clusteradd")
self.add_mode(self.__cluster_add)
- def get_title(self, session, model):
- return "Messaging"
+ def get_title(self, session, object):
+ return "Main"
+ class MessagingTab(Widget):
+ def render_content(self, session, object):
+ return "Messaging"
+
+ def render_href(self, session, object):
+ branch = session.branch()
+ frame = self.page().show_main(branch).show_view(branch)
+ frame.show_messaging(branch)
+ return branch.marshal()
+
+ class GridTab(Widget):
+ def render_content(self, session, object):
+ return "Grid"
+
+ def render_href(self, session, object):
+ branch = session.branch()
+ frame = self.page().show_main(branch).show_view(branch)
+ frame.show_grid(branch)
+ return branch.marshal()
+
+ class SystemsTab(Widget):
+ def render_content(self, session, object):
+ return "Systems"
+
+ def render_href(self, session, object):
+ branch = session.branch()
+ frame = self.page().show_main(branch).show_view(branch)
+ frame.show_systems(branch)
+ return branch.marshal()
+
+ def render_tabs(self, session, object):
+ writer = Writer()
+
+ for tab in self.__tabs:
+ self.__tab_tmpl.render(session, (tab, object), writer)
+
+ return writer.to_string()
+
+ def render_tab_href(self, session, args):
+ tab, object = args
+ return tab.render_href(session, object)
+
+ def render_tab_content(self, session, args):
+ tab, object = args
+ return tab.render_content(session, object)
+
+ def render_frames(self, session, object):
+ self.__object.set(session, object)
+ writer = Writer()
+
+ for frame in self.page().get_frames(session):
+ self.__frame_tmpl.render(session, frame, writer)
+
+ return writer.to_string()
+
+ def render_frame_href(self, session, frame):
+ object = frame.get_object(session, self.__object.get(session))
+ return frame.render_href(session, object)
+
+ def render_frame_title(self, session, frame):
+ object = frame.get_object(session, self.__object.get(session))
+ return frame.render_title(session, object)
+
+ def render_pending_count(self, session, object):
+ return self.app.model.count_invocations("pending")
+
+ def render_completed_count(self, session, object):
+ return self.app.model.count_invocations("OK")
+
+ def render_failed_count(self, session, object):
+ pcount = self.app.model.count_invocations("pending")
+ ccount = self.app.model.count_invocations("OK")
+ return len(self.app.model.invocations) - pcount - ccount
+
def show_broker(self, session, broker):
cluster = None #broker.get_broker_cluster()
@@ -203,18 +235,28 @@
frame = self.show_mode(session, self.__cluster_add)
return self.page().set_current_frame(session, frame)
-# def show_queue(self, session, queue):
-# frame = self.show_broker(session, queue.vhost.broker.registration)
-# return frame.show_queue(session, queue)
+class MainView(ModeSet):
+ def __init__(self, app, name):
+ super(MainView, self).__init__(app, name)
-# def show_exchange(self, session, exchange):
-# frame = self.show_broker(session, exchange.vhost.broker.registration)
-# return frame.show_exchange(session, exchange)
+ self.__messaging = MessagingView(app, "msg")
+ self.add_mode(self.__messaging)
-# def show_client(self, session, client):
-# frame = self.show_broker(session, client.vhost.broker.registration)
-# return frame.show_client(session, client)
+ self.__grid = GridView(app, "grd")
+ self.add_mode(self.__grid)
+ self.__systems = SystemsView(app, "sys")
+ self.add_mode(self.__systems)
+
+ def show_messaging(self, session):
+ return self.show_mode(session, self.__messaging)
+
+ def show_grid(self, session):
+ return self.show_mode(session, self.__grid)
+
+ def show_systems(self, session):
+ return self.show_mode(session, self.__systems)
+
class MessagingView(TabSet):
def __init__(self, app, name):
super(MessagingView, self).__init__(app, name)
@@ -225,11 +267,6 @@
#self.add_tab(BrokerClusterSet(app, "clusters"))
#self.add_tab(self.TagTab(app, "tags"))
- def show_broker_group(self, session, group):
- mode = self.show_mode(session, self.brokers)
- mode.set_object(session, group)
- return mode
-
def get_title(self, session, model):
return "Messaging"
@@ -240,17 +277,6 @@
def get_title(self, session, model):
return "Tags"
-class GridFrame(CuminFrame):
- def __init__(self, app, name):
- super(GridFrame, self).__init__(app, name)
-
- self.__view = GridView(app, "view")
- self.add_mode(self.__view)
- self.set_view_mode(self.__view)
-
- def get_title(self, session, model):
- return "Grid"
-
class GridView(TabSet):
def get_title(self, session, model):
return "Grid"
@@ -258,17 +284,6 @@
def render_data_url(self, session, model):
return "model.xml"
-class SystemsFrame(CuminFrame):
- def __init__(self, app, name):
- super(SystemsFrame, self).__init__(app, name)
-
- self.__view = SystemsView(app, "view")
- self.add_mode(self.__view)
- self.set_view_mode(self.__view)
-
- def get_title(self, session, model):
- return "Systems"
-
class SystemsView(TabSet):
def __init__(self, app, name):
super(SystemsView, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings 2008-02-04 17:55:32 UTC (rev 1638)
+++ mgmt/cumin/python/cumin/page.strings 2008-02-04 17:55:54 UTC (rev 1639)
@@ -558,7 +558,7 @@
</body>
</html>
-[MainView.css]
+[MainFrame.css]
#head {
padding: 0;
background-color: #666;
@@ -659,7 +659,7 @@
content: "";
}
-[MainView.javascript]
+[MainFrame.javascript]
function updateActions(id, model) {
var pcount = model.invocations.pending;
var ccount = model.invocations.completed;
@@ -690,7 +690,7 @@
cumin.runModelListeners(model);
}
-[MainView.html]
+[MainFrame.html]
<div id="head">
<div>
<ul id="user">
@@ -721,7 +721,10 @@
<div id="body">{mode}</div>
<div id="foot"/>
-[MainView.frame_html]
+[MainFrame.tab_html]
+<li><a href="{tab_href}"
class="{tab_class}">{tab_content}</a></li>
+
+[MainFrame.frame_html]
<li><a href="{frame_href}">{frame_title}</a></li>
[MessagingView.html]
@@ -742,7 +745,7 @@
<div class="TabSet mode">{mode}</div>
</div>
-[SystemView.html]
+[SystemsView.html]
<script>
wooly.setIntervalUpdate("{data_url}", updateMain, 3000);
</script>