[rhmessaging-commits] rhmessaging commits: r3195 - mgmt/trunk/wooly/python/wooly.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Fri Mar 20 17:49:24 EDT 2009


Author: justi9
Date: 2009-03-20 17:49:24 -0400 (Fri, 20 Mar 2009)
New Revision: 3195

Modified:
   mgmt/trunk/wooly/python/wooly/pages.py
   mgmt/trunk/wooly/python/wooly/pages.strings
Log:
Only run update javascript if there are widgets requesting updates

Modified: mgmt/trunk/wooly/python/wooly/pages.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/pages.py	2009-03-20 21:47:57 UTC (rev 3194)
+++ mgmt/trunk/wooly/python/wooly/pages.py	2009-03-20 21:49:24 UTC (rev 3195)
@@ -79,6 +79,9 @@
         self.updates = self.UpdatesAttribute(app, "updates")
         self.add_attribute(self.updates)
 
+        self.update_script = UpdateScript(app, "update_script", self)
+        self.add_child(self.update_script)
+
         self.update_page = UpdatePage(app, name + ".update", self)
         self.app.add_page(self.update_page)
 
@@ -91,9 +94,6 @@
     def enable_update(self, session, widget):
         self.updates.get(session).append(widget)
 
-    def render_update_url(self, session):
-        return self.get_update_url(session, self.updates.get(session))
-
     def get_update_url(self, session, widgets):
         sess = Session(self.page.update_page)
 
@@ -106,6 +106,20 @@
         def get_default(self, session):
             return list()
 
+class UpdateScript(Widget):
+    def __init__(self, app, name, html_page):
+        super(UpdateScript, self).__init__(app, name)
+
+        self.html_page = html_page
+
+    def do_render(self, session):
+        if self.html_page.updates.get(session):
+            return super(UpdateScript, self).do_render(session)
+
+    def render_url(self, session):
+        updates = self.html_page.updates.get(session)
+        return self.html_page.get_update_url(session, updates)
+
 class UpdatePage(Page):
     def __init__(self, app, name, html_page):
         super(UpdatePage, self).__init__(app, name)

Modified: mgmt/trunk/wooly/python/wooly/pages.strings
===================================================================
--- mgmt/trunk/wooly/python/wooly/pages.strings	2009-03-20 21:47:57 UTC (rev 3194)
+++ mgmt/trunk/wooly/python/wooly/pages.strings	2009-03-20 21:49:24 UTC (rev 3195)
@@ -16,18 +16,20 @@
 
     <script type="text/javascript" src="resource?name=wooly.js"> </script>
     <script type="text/javascript" src="resource?name=app.js"> </script>
-    <script type="text/javascript" src="{id}.js"> </script>
-    <script type="text/javascript">
-      // <![CDATA[
-      wooly.newSetIntervalUpdate('{update_url}', wooly.updatePage, 3000);
-      // ]]>
-    </script>
+    {update_script}
   </head>
   <body class="{class}">
     {content}
   </body>
 </html>
 
+[UpdateScript.html]
+<script type="text/javascript">
+  // <![CDATA[
+  wooly.newSetIntervalUpdate('{url}', wooly.updatePage, 3000);
+  // ]]>
+</script>
+
 [UpdatePage.html]
 <?xml version="1.0" encoding="UTF-8"?>
 <widgets>{widgets}</widgets>




More information about the rhmessaging-commits mailing list