Author: justi9
Date: 2007-10-12 17:48:58 -0400 (Fri, 12 Oct 2007)
New Revision: 1031
Modified:
mgmt/cumin/python/wooly/widgets.py
mgmt/cumin/python/wooly/widgets.strings
Log:
Makes TabSet use a child template for rendering tabs.
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2007-10-12 21:03:35 UTC (rev 1030)
+++ mgmt/cumin/python/wooly/widgets.py 2007-10-12 21:48:58 UTC (rev 1031)
@@ -44,6 +44,11 @@
def __init__(self, app, name):
super(TabSet, self).__init__(app, name)
+ self.tab_tmpl = Template(self, "tab_html")
+
+ self.object = Attribute(app, "object")
+ self.add_attribute(self.object)
+
def do_render(self, session, object):
writer = Writer()
@@ -51,24 +56,26 @@
return writer.to_string()
- # XXX make this use an item template
def render_tabs(self, session, object):
+ self.object.set(session, object)
writer = Writer()
- str = """<li><a href="%s"
class="%s">%s</a></li>"""
for mode in self.children:
- branch = session.branch()
- self.set_selected_mode(branch, mode)
- href = branch.marshal()
+ self.tab_tmpl.render(session, mode, writer)
- smode = self.get_selected_mode(session)
- selected = smode == mode and "selected" or ""
+ return writer.to_string()
- content = mode.render_title(session, object)
+ def render_tab_href(self, session, mode):
+ branch = session.branch()
+ self.set_selected_mode(branch, mode)
+ return branch.marshal()
- writer.write(str % (href, selected, content))
+ def render_tab_class(self, session, mode):
+ smode = self.get_selected_mode(session)
+ return smode == mode and "selected" or ""
- return writer.to_string()
+ def render_tab_content(self, session, mode):
+ return mode.render_title(session, self.object.get(session))
def render_mode(self, session, object):
mode = self.get_selected_mode(session)
Modified: mgmt/cumin/python/wooly/widgets.strings
===================================================================
--- mgmt/cumin/python/wooly/widgets.strings 2007-10-12 21:03:35 UTC (rev 1030)
+++ mgmt/cumin/python/wooly/widgets.strings 2007-10-12 21:48:58 UTC (rev 1031)
@@ -42,6 +42,9 @@
<ul class="TabSet tabs">{tabs}</ul>
<div class="TabSet mode">{mode}</div>
+[TabSet.tab_html]
+<li><a href="{tab_href}"
class="{tab_class}">{tab_content}</a></li>
+
[Link.html]
<a href="{href}">{content}</a>
Show replies by date