[rhmessaging-commits] rhmessaging commits: r3314 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Apr 20 15:49:23 EDT 2009


Author: justi9
Date: 2009-04-20 15:49:23 -0400 (Mon, 20 Apr 2009)
New Revision: 3314

Modified:
   mgmt/trunk/cumin/python/cumin/page.py
   mgmt/trunk/cumin/python/cumin/page.strings
   mgmt/trunk/cumin/python/cumin/widgets.py
   mgmt/trunk/cumin/python/cumin/widgets.strings
Log:
Refactor part of MainView into a base class, so other top-level UIs can use it

Modified: mgmt/trunk/cumin/python/cumin/page.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/page.py	2009-04-20 18:55:47 UTC (rev 3313)
+++ mgmt/trunk/cumin/python/cumin/page.py	2009-04-20 19:49:23 UTC (rev 3314)
@@ -26,22 +26,20 @@
     def __init__(self, app, name):
         super(MainPage, self).__init__(app, name)
 
-        self.main = MainFrame(app, "main")
+        self.main = MainView(app, "main")
         self.add_mode(self.main)
         self.set_default_frame(self.main)
 
+        # for form in model actions:
+        #    seld.add_mode(form)
+
     def render_title(self, session):
         return "MRG Management"
 
-class MainFrame(TabbedModeSet):
+class MainView(CuminMainView):
     def __init__(self, app, name):
-        super(MainFrame, self).__init__(app, name)
+        super(MainView, self).__init__(app, name)
 
-        self.__frame_tmpl = Template(self, "frame_html")
-
-        self.actions = ActionInvocationStatus(app, "actions")
-        self.add_child(self.actions)
-
         self.home = HomeFrame(app, "home")
         self.add_tab(self.home)
 
@@ -54,31 +52,6 @@
         self.inventory = InventoryFrame(app, "inventory")
         self.add_tab(self.inventory)
 
-    def show_child(self, session, child):
-        super(MainFrame, self).show_child(session, child)
-
-        frame = self.page.get_frame(session)
-
-        if child not in frame.ancestors:
-            self.page.set_frame(session, child)
-
-    def render_title(self, session):
-        return "Main"
-
-    def render_user_name(self, session):
-        if hasattr(session, "user_session"):
-            return session.user_session.subject.name
-
-    def render_logout_href(self, session):
-        page = self.app.login_page
-
-        lsess = Session(page)
-
-        page.logout.set(lsess, True)
-        page.origin.set(lsess, session.marshal())
-
-        return lsess.marshal()
-
 class HomeFrame(CuminFrame):
     def __init__(self, app, name):
         super(HomeFrame, self).__init__(app, name)

Modified: mgmt/trunk/cumin/python/cumin/page.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/page.strings	2009-04-20 18:55:47 UTC (rev 3313)
+++ mgmt/trunk/cumin/python/cumin/page.strings	2009-04-20 19:49:23 UTC (rev 3314)
@@ -1,87 +1,3 @@
-[MainFrame.css]
-#head {
-    padding: 0;
-    min-height: 2.75em;
-    background: #f9f9ff url("resource?name=shade.png") repeat-x scroll bottom center;
-}
-
-#logo {
-    float: left;
-    margin: 0.25em 1em;
-}
-
-#tabs {
-    padding: 0 0 0 2em;
-    position: relative;
-    top: 1.175em;
-}
-
-#tabs li {
-    display: inline;
-}
-
-#tabs li a {
-    padding: 0.275em 0.5em;
-    border-top: 1px solid #ccc;
-    border-right: 1px solid #ccc;
-    border-left: 1px solid #e7e7e7;
-    -moz-border-radius: 0.35em 0.35em 0 0;
-    -webkit-border-radius: 0.35em 0.35em 0 0;
-    color: #333;
-    background-color: #f7f7f7;
-    line-height: 1.6em;
-}
-
-#tabs li:first-child a {
-    border-left: 1px solid #ccc;
-}
-
-#tabs li a.selected {
-    background-color: #fff;
-    position: relative;
-    z-index: 2;
-}
-
-#user {
-    padding: 0.25em 0.5em;
-    float: right;
-    font-size: 0.9em;
-}
-
-#actions {
-    padding: 0.25em 0.5em;
-    float: right;
-    font-size: 0.9em;
-}
-
-#body {
-  border-top: 1px solid #ccc;
-  padding: 0.75em 1em;
-  position: relative;
-  z-index: 1;
-  min-height: 20em;
-}
-
-[MainFrame.html]
-<div id="head">
-  <div id="user">
-    Hi, {user_name}
-    <strong>&#183;</strong>
-    <a id="logout" onclick="wooly.clearUpdates()" href="{logout_href}">Log Out</a>
-  </div>
-
-  <img id="logo" src="resource?name=rhlogo-32.png"/>
-
-  <ul id="tabs">{tabs}</ul>
-</div>
-
-<div id="body">{content}</div>
-
-<div id="foot"/>
-
-[MainFrame.frame_html]
-<li><a href="{frame_href}">{frame_title}</a></li>
-
 [HomeView.html]
 <div class="oblock">
   {heading}

Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py	2009-04-20 18:55:47 UTC (rev 3313)
+++ mgmt/trunk/cumin/python/cumin/widgets.py	2009-04-20 19:49:23 UTC (rev 3314)
@@ -1,6 +1,5 @@
 from datetime import datetime, timedelta
 from sqlobject import sqlhub
-from sqlobject.sresults import SelectResults
 from wooly import *
 from wooly.pages import *
 from wooly.widgets import *
@@ -14,6 +13,7 @@
 from util import *
 
 import time
+from wooly import Session
 
 strings = StringCatalog(__file__)
 
@@ -44,6 +44,37 @@
         def get_default(self, session):
             return list()
 
+class CuminMainView(TabbedModeSet):
+    def __init__(self, app, name):
+        super(CuminMainView, self).__init__(app, name)
+
+        self.__frame_tmpl = Template(self, "frame_html")
+
+        #self.actions = ActionInvocationStatus(app, "actions")
+        #self.add_child(self.actions)
+
+    def show_child(self, session, child):
+        super(CuminMainView, self).show_child(session, child)
+
+        frame = self.page.get_frame(session)
+
+        if child not in frame.ancestors:
+            self.page.set_frame(session, child)
+
+    def render_user_name(self, session):
+        if hasattr(session, "user_session"):
+            return session.user_session.subject.name
+
+    def render_logout_href(self, session):
+        page = self.app.login_page
+
+        lsess = Session(page)
+
+        page.logout.set(lsess, True)
+        page.origin.set(lsess, session.marshal())
+
+        return lsess.marshal()
+
 class CuminFrame(Frame, ModeSet):
     def __init__(self, app, name):
         super(CuminFrame, self).__init__(app, name)
@@ -562,7 +593,7 @@
 
     def get_click(self, state):
         return ""
-        
+
     def get_attributes(self, state):
         return dict()
 

Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings	2009-04-20 18:55:47 UTC (rev 3313)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings	2009-04-20 19:49:23 UTC (rev 3314)
@@ -16,6 +16,90 @@
 left outer join binding_stats as c on c.id = b.stats_curr_id
 {sql_where}
 
+[CuminMainView.css]
+#head {
+    padding: 0;
+    min-height: 2.75em;
+    background: #f9f9ff url("resource?name=shade.png") repeat-x scroll bottom center;
+}
+
+#logo {
+    float: left;
+    margin: 0.25em 1em;
+}
+
+#tabs {
+    padding: 0 0 0 2em;
+    position: relative;
+    top: 1.175em;
+}
+
+#tabs li {
+    display: inline;
+}
+
+#tabs li a {
+    padding: 0.275em 0.5em;
+    border-top: 1px solid #ccc;
+    border-right: 1px solid #ccc;
+    border-left: 1px solid #e7e7e7;
+    -moz-border-radius: 0.35em 0.35em 0 0;
+    -webkit-border-radius: 0.35em 0.35em 0 0;
+    color: #333;
+    background-color: #f7f7f7;
+    line-height: 1.6em;
+}
+
+#tabs li:first-child a {
+    border-left: 1px solid #ccc;
+}
+
+#tabs li a.selected {
+    background-color: #fff;
+    position: relative;
+    z-index: 2;
+}
+
+#user {
+    padding: 0.25em 0.5em;
+    float: right;
+    font-size: 0.9em;
+}
+
+#actions {
+    padding: 0.25em 0.5em;
+    float: right;
+    font-size: 0.9em;
+}
+
+#body {
+  border-top: 1px solid #ccc;
+  padding: 0.75em 1em;
+  position: relative;
+  z-index: 1;
+  min-height: 20em;
+}
+
+[CuminMainView.html]
+<div id="head">
+  <div id="user">
+    Hi, {user_name}
+    <strong>&#183;</strong>
+    <a id="logout" onclick="wooly.clearUpdates()" href="{logout_href}">Log Out</a>
+  </div>
+
+  <img id="logo" src="resource?name=rhlogo-32.png"/>
+
+  <ul id="tabs">{tabs}</ul>
+</div>
+
+<div id="body">{content}</div>
+
+<div id="foot"/>
+
+[CuminMainView.frame_html]
+<li><a href="{frame_href}">{frame_title}</a></li>
+
 [CuminView.css]
 ul.context {
     display: inline;




More information about the rhmessaging-commits mailing list