Author: justi9
Date: 2007-10-14 10:32:02 -0400 (Sun, 14 Oct 2007)
New Revision: 1061
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/server.strings
mgmt/cumin/python/cumin/virtualhost.py
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/wooly/__init__.py
mgmt/notes/Todo
Log:
Moves the get_object machinery down into Widget and out of CuminFrame.
Removes ServerGroupFrame.
Modified: mgmt/cumin/python/cumin/cluster.py
===================================================================
--- mgmt/cumin/python/cumin/cluster.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/cluster.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -46,7 +46,6 @@
self.param = ClusterParameter(app, "id")
self.add_parameter(self.param)
- self.set_object_attribute(self.param)
self.view = ClusterView(app, "view")
self.add_child(self.view)
@@ -57,6 +56,9 @@
self.vhost = VirtualHostFrame(app, "vhost")
self.add_child(self.vhost)
+ def get_object(self, session, object):
+ return self.param.get(session)
+
def set_cluster(self, session, cluster):
self.param.set(session, cluster)
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/exchange.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -61,11 +61,13 @@
self.param = ExchangeParameter(app, "id")
self.add_parameter(self.param)
- self.set_object_attribute(self.param)
self.view = ExchangeView(app, "view")
self.add_child(self.view)
+ def get_object(self, session, object):
+ return self.param.get(session)
+
def set_exchange(self, session, exchange):
return self.param.set(session, exchange)
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/page.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -16,6 +16,9 @@
self.frames = self.FramesAttribute(app, "frames")
self.add_attribute(self.frames)
+ self.object = Attribute(app, "object")
+ self.add_attribute(self.object)
+
self.modal = Attribute(app, "modal")
self.add_attribute(self.modal)
@@ -89,6 +92,7 @@
return self.frames.get(session)
def render_frames(self, session, object):
+ self.object.set(session, object)
writer = Writer()
for frame in self.get_frames(session):
@@ -97,10 +101,12 @@
return writer.to_string()
def render_frame_href(self, session, frame):
- return frame.render_href(session, frame.get_object(session))
+ object = frame.get_object(session, self.object.get(session))
+ return frame.render_href(session, object)
def render_frame_title(self, session, frame):
- return frame.render_title(session, frame.get_object(session))
+ object = frame.get_object(session, self.object.get(session))
+ return frame.render_title(session, object)
class MainFrame(CuminFrame):
def __init__(self, app, name):
@@ -118,7 +124,7 @@
self.group_add = ServerGroupAdd(app, "group_add")
self.add_child(self.group_add)
- def get_object(self, session):
+ def get_object(self, session, object):
return self.app.model
def show_view(self, session):
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/queue.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -64,11 +64,13 @@
self.param = QueueParameter(app, "id")
self.add_parameter(self.param)
- self.set_object_attribute(self.param)
self.view = QueueView(app, "view")
self.add_child(self.view)
+ def get_object(self, session, object):
+ return self.param.get(session)
+
def set_queue(self, session, queue):
return self.param.set(session, queue)
Modified: mgmt/cumin/python/cumin/server.py
===================================================================
--- mgmt/cumin/python/cumin/server.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/server.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -44,7 +44,6 @@
self.param = ServerParameter(app, "id")
self.add_parameter(self.param)
- self.set_object_attribute(self.param)
self.view = ServerView(app, "view")
self.add_child(self.view)
@@ -52,6 +51,9 @@
self.vhost = VirtualHostFrame(app, "vhost")
self.add_child(self.vhost)
+ def get_object(self, session, object):
+ return self.param.get(session)
+
def set_server(self, session, server):
self.param.set(session, server)
@@ -136,7 +138,7 @@
def __init__(self, app, name):
super(ServerBrowser, self).__init__(app, name)
- self.param = ServerGroupParameter(app, "param")
+ self.param = ServerGroupParameter(app, "group")
self.add_parameter(self.param)
self.groups = self.BrowserGroups(app, "groups")
@@ -160,12 +162,12 @@
self.page().main.show_group_add(branch)
return branch.marshal()
- def render_remove_group_link(self, session, model):
+ def render_remove_group_href(self, session, model):
group = self.param.get(session)
if group:
branch = session.branch()
- return "<li>%s</li>" % link(branch.marshal(),
"Remove This Group")
+ return branch.marshal()
class BrowserGroups(Widget):
def __init__(self, app, name):
@@ -220,16 +222,6 @@
def do_marshal(self, group):
return str(group.id)
-class ServerGroupFrame(CuminFrame):
- def __init__(self, app, name):
- super(ServerGroupFrame, self).__init__(app, name)
-
- self.add = ServerGroupAdd(app, "add")
- self.add_child(self.add)
-
- self.edit = ServerGroupEdit(app, "edit")
- self.add_child(self.edit)
-
class ServerGroupForm(CuminForm):
def __init__(self, app, name):
super(ServerGroupForm, self).__init__(app, name)
@@ -237,7 +229,7 @@
self.group_name = TextInput(app, "name", self)
self.add_child(self.group_name)
-class ServerGroupAdd(ServerGroupForm):
+class ServerGroupAdd(ServerGroupForm, Frame):
def render_title(self, session, model):
return "Add Group"
@@ -247,5 +239,22 @@
session.set_redirect(branch.marshal())
class ServerGroupEdit(ServerGroupForm):
+ def __init__(self, app, name):
+ super(ServerGroupEdit, self).__init__(app, name)
+
+ self.param = ServerGroupParameter(app, "id")
+ self.add_parameter(self.param)
+
+ def get_object(self, session):
+ return self.param.get(session)
+
+ def set_server_group(self, session, group):
+ self.param.set(session, group)
+
def render_title(self, session, group):
return "Edit Group '%s'" % group.name
+
+ def on_cancel(self, session, model):
+ branch = session.branch()
+ self.page().main.show_view(branch)
+ session.set_redirect(branch.marshal())
Modified: mgmt/cumin/python/cumin/server.strings
===================================================================
--- mgmt/cumin/python/cumin/server.strings 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/server.strings 2007-10-14 14:32:02 UTC (rev 1061)
@@ -76,7 +76,7 @@
margin: 0 0 1em 0;
}
-.ServerBrowser.groups ul li {
+.ServerBrowser.groups ul.groups li {
margin: 0 0 0 0.5em;
}
@@ -96,19 +96,23 @@
[ServerBrowser.html]
<div class="ServerBrowser groups">
<h2>Selection</h2>
- <ul><li>{all_servers_link}</li></ul>
+ <ul class="groups"><li>{all_servers_link}</li></ul>
{groups}
<ul class="actions">
- <li><a href="{add_group_href}">Add Group</a>
+ <li><a href="{add_group_href}">Add Group</a></li>
</ul>
+
+ <ul class="actions">
+ <li><a href="{edit_group_href}">Edit
Group</a></li>
+ <li><a href="{remove_group_href}">Remove
Group</a></li>
+ </ul>
</div>
<div class="ServerBrowser servers">
<ul class="actions">
<li><a href="">Add Server</a></li>
<li><a href="">Shutdown Servers</a></li>
- {remove_group_link}
</ul>
{servers}
@@ -119,7 +123,7 @@
[BrowserGroups.type_html]
<h2>{type_name}</h2>
-<ul>{groups}</ul>
+<ul class="groups">{groups}</ul>
[BrowserGroups.group_html]
<li>{group_link}</li>
Modified: mgmt/cumin/python/cumin/virtualhost.py
===================================================================
--- mgmt/cumin/python/cumin/virtualhost.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/virtualhost.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -34,7 +34,6 @@
self.param = VirtualHostParameter(app, "id")
self.add_parameter(self.param)
- self.set_object_attribute(self.param)
self.queue = QueueFrame(app, "queue")
self.add_child(self.queue)
@@ -45,6 +44,9 @@
self.view = VirtualHostView(app, "view")
self.add_child(self.view)
+ def get_object(self, session, object):
+ return self.param.get(session)
+
def set_virtual_host(self, session, vhost):
return self.param.set(session, vhost)
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/cumin/widgets.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -15,31 +15,14 @@
return "<span class=\"none\">None</span>"
class CuminFrame(Frame, ModeSet):
- def __init__(self, app, name):
- super(CuminFrame, self).__init__(app, name)
-
- self.object = None
-
- def set_object_attribute(self, attribute):
- self.object = attribute
-
- def get_object(self, session):
- if self.object:
- return self.object.get(session)
-
def show_view(self, session):
pass
def do_process(self, session, object):
self.page().get_frames(session).append(self)
- new_object = self.get_object(session)
- super(CuminFrame, self).do_process(session, new_object)
+ super(CuminFrame, self).do_process(session, object)
- def do_render(self, session, object):
- new_object = self.get_object(session)
- return super(CuminFrame, self).do_render(session, new_object)
-
def render_href(self, session, vhost):
branch = session.branch()
self.page().set_current_frame(branch, self)
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/cumin/python/wooly/__init__.py 2007-10-14 14:32:02 UTC (rev 1061)
@@ -108,12 +108,16 @@
return params
+ def get_object(self, session, object):
+ return object
+
def process(self, session, object):
if session.debug:
call = WidgetCall(session.debug.process_stack,
self, session, object)
call.open()
+ object = self.get_object(session, object)
self.do_process(session, object)
if session.debug:
@@ -129,6 +133,7 @@
self, session, object)
call.open()
+ object = self.get_object(session, object)
string = self.do_render(session, object)
if session.debug:
Modified: mgmt/notes/Todo
===================================================================
--- mgmt/notes/Todo 2007-10-14 13:11:12 UTC (rev 1060)
+++ mgmt/notes/Todo 2007-10-14 14:32:02 UTC (rev 1061)
@@ -70,4 +70,7 @@
* Consider having a cssclass set on widgets
- * Use page attributes for session errors, redirect
\ No newline at end of file
+ * Use page attributes for session errors, redirect
+
+ * See if we can eliminate the attr/param distinction, and use whether
+ or not a param is added to a widget via add_param to do that