Author: justi9
Date: 2008-03-27 00:49:04 -0400 (Thu, 27 Mar 2008)
New Revision: 1800
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokergroup.py
mgmt/cumin/python/cumin/brokerprofile.py
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/stat.py
mgmt/cumin/python/cumin/system.py
mgmt/cumin/python/cumin/virtualhost.py
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/wooly/__init__.py
mgmt/cumin/python/wooly/forms.py
mgmt/cumin/python/wooly/parameters.py
mgmt/cumin/python/wooly/widgets.py
mgmt/misc/boneyard.py
Log:
Now that we have an init() pass, we can set widget relation just once
at start time. This has a nice performance impact for common
operations such as marshal_url_vars().
Changes the path(), page(), and frame() methods to be simple
attributes with precomputed values.
Gets rid of the get_child(name) method in favor of a member dict,
widget.children_by_name.
Changes the api for saving parameters.
widget.save_parameters(session, list) is now the way to edit
the set of parameters saved between page loads.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/broker.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -57,13 +57,13 @@
self.parent.ids.clear(session)
branch = session.branch()
- frame = self.frame().show_brokers_remove(branch)
+ frame = self.frame.show_brokers_remove(branch)
frame.ids.set(branch, ids)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.set_redirect_url(session, branch.marshal())
class BrokerSetGroupInput(BrokerGroupInput):
def render_submit_id(self, session):
- return self.parent.groupify.path()
+ return self.parent.groupify.path
class Groupify(FormButton):
def render_content(self, session):
@@ -83,7 +83,7 @@
except IntegrityError:
pass
- self.page().set_redirect_url(session, session.marshal())
+ self.page.set_redirect_url(session, session.marshal())
class NameColumn(SqlTableColumn):
def render_title(self, session, data):
@@ -131,7 +131,7 @@
self.add_column(col)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, broker):
count = self.get_item_count(session, broker)
@@ -189,25 +189,25 @@
def show_queue(self, session, queue):
self.queue.set_object(session, queue)
- self.page().set_current_frame(session, self.queue)
+ self.page.set_current_frame(session, self.queue)
return self.show_mode(session, self.queue)
def show_queues_purge(self, session):
- self.page().set_current_frame(session, self.queues_purge)
+ self.page.set_current_frame(session, self.queues_purge)
return self.show_mode(session, self.queues_purge)
def show_exchange(self, session, exchange):
self.exchange.set_object(session, exchange)
- self.page().set_current_frame(session, self.exchange)
+ self.page.set_current_frame(session, self.exchange)
return self.show_mode(session, self.exchange)
def show_client(self, session, client):
self.client.set_object(session, client)
- self.page().set_current_frame(session, self.client)
+ self.page.set_current_frame(session, self.client)
return self.show_mode(session, self.client)
def show_clients_close(self, session):
- self.page().set_current_frame(session, self.clients_close)
+ self.page.set_current_frame(session, self.clients_close)
return self.show_mode(session, self.clients_close)
def render_title(self, session, broker):
@@ -273,7 +273,7 @@
for group in reg.groups:
branch = session.branch()
- self.frame().frame().show_broker_group(branch, group).show_view \
+ self.frame.frame.show_broker_group(branch, group).show_view \
(branch)
links.append(fmt_olink(branch, group))
@@ -284,7 +284,7 @@
if cluster:
branch = session.branch()
- self.page().show_broker_cluster(branch, cluster).show_view(branch)
+ self.page.show_broker_cluster(branch, cluster).show_view(branch)
return fmt_olink(branch, cluster)
else:
return fmt_none()
@@ -294,7 +294,7 @@
if profile:
branch = session.branch()
- self.page().show_broker_profile(branch, profile).show_view(branch)
+ self.page.show_broker_profile(branch, profile).show_view(branch)
return fmt_olink(branch, profile)
else:
return fmt_none()
@@ -307,7 +307,7 @@
self.add_child(self.__queues)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, reg):
vhost = reg.getDefaultVhost()
@@ -315,12 +315,12 @@
def render_add_queue_href(self, session, reg):
branch = session.branch()
- self.frame().show_queue(branch, None).show_add(branch)
+ self.frame.show_queue(branch, None).show_add(branch)
return branch.marshal()
class BrokerExchangeTab(ExchangeSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, reg):
vhost = reg.getDefaultVhost()
@@ -329,7 +329,7 @@
class BrokerClientTab(ClientSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, reg):
vhost = reg.getDefaultVhost()
@@ -338,14 +338,14 @@
class BrokerStatsTab(Widget):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, reg):
return "Statistics"
class BrokerLogTab(Widget):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, reg):
return "Log Messages"
@@ -393,7 +393,7 @@
def render_add_broker_href(self, session):
branch = session.branch()
- self.frame().show_brokers_add(branch)
+ self.frame.show_brokers_add(branch)
return branch.marshal()
def render_clear_filters_href(self, session):
@@ -507,7 +507,7 @@
return writer.to_string()
def render_field_name_name(self, session, index):
- return self.names.path()
+ return self.names.path
def render_field_name_value(self, session, index):
names = self.names.get(session)
@@ -521,7 +521,7 @@
"</li><li>".join(errors[index])
def render_field_address_name(self, session, index):
- return self.addrs.path()
+ return self.addrs.path
def render_field_address_value(self, session, index):
addrs = self.addrs.get(session)
@@ -535,7 +535,7 @@
"</li><li>".join(errors[index])
def render_field_group_name(self, session, index):
- return self.groups.path()
+ return self.groups.path
def render_groups(self, session, index):
writer = Writer()
@@ -564,8 +564,8 @@
class BrokerSetAdd(BrokerSetForm):
def process_cancel(self, session):
branch = session.branch()
- self.frame().show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session):
action = self.app.model.broker_registration.add
@@ -644,19 +644,19 @@
def init(self):
super(BrokerEdit, self).init()
- self.broker_name.set_object_attr(self.frame().get_object_parameter())
+ self.broker_name.set_object_attr(self.frame.get_object_parameter())
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, reg):
return "Edit Broker '%s'" % reg.name
def process_cancel(self, session, reg):
branch = session.branch()
- self.page().pop_current_frame(branch)
- self.page().get_current_frame(branch).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.pop_current_frame(branch)
+ self.page.get_current_frame(branch).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, reg):
errors = self.validate(session)
@@ -688,20 +688,20 @@
class BrokerRemove(CuminConfirmForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, reg):
branch = session.branch()
- self.frame().show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, reg):
action = self.app.model.broker_registration.remove
action.invoke(reg)
branch = session.branch()
- self.page().show_main(branch).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_main(branch).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, reg):
return "Unregister Broker '%s'" % reg.name
@@ -715,10 +715,9 @@
class BrokerSetRemove(CuminBulkActionForm, Frame):
def process_return(self, session):
branch = session.branch()
- frame = self.frame()
- frame.show_view(branch)
- self.page().set_current_frame(branch, frame)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.set_current_frame(branch, self.frame)
+ self.page.set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
action = self.app.model.broker_registration.remove
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/brokercluster.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -15,7 +15,7 @@
class BrokerClusterSet(SQLObjectItemSet):
def render_cluster_add_href(self, session, *args):
branch = session.branch()
- self.page().show_broker_cluster_add(branch)
+ self.page.show_broker_cluster_add(branch)
return branch.marshal()
def render_title(self, session, *args):
@@ -26,7 +26,7 @@
def render_item_link(self, session, cluster):
branch = session.branch()
- self.page().show_broker_cluster(branch, cluster).show_view(branch)
+ self.page.show_broker_cluster(branch, cluster).show_view(branch)
return fmt_olink(branch, cluster)
def render_item_config(self, session, cluster):
@@ -94,7 +94,7 @@
class ClusterBrokerTab(BrokerSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, cluster):
return "Brokers %s" % fmt_count(len(cluster.brokers))
@@ -104,7 +104,7 @@
class ClusterStatsTab(Widget):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, cluster):
return "Statistics"
@@ -120,8 +120,8 @@
cluster.name = self.cluster_name.get(session)
branch = session.branch()
- self.page().show_broker_cluster(branch, cluster).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_broker_cluster(branch, cluster).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
class BrokerClusterAdd(BrokerClusterForm, Frame):
def render_title(self, session):
@@ -129,8 +129,8 @@
def process_cancel(self, session):
branch = session.branch()
- self.page().show_main(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_main(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session):
cluster = BrokerCluster()
@@ -138,12 +138,12 @@
class BrokerClusterEdit(BrokerClusterForm, Frame):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, cluster):
branch = session.branch()
self.parent.show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, cluster):
self.process_cluster(session, cluster)
@@ -160,15 +160,15 @@
def process_cancel(self, session, cluster):
branch = session.branch()
- self.page().show_broker_cluster(branch, cluster).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_broker_cluster(branch, cluster).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, cluster):
cluster.destroySelf()
branch = session.branch()
- self.page().show_main(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_main(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, cluster):
return "Remove Broker Cluster '%s'" % cluster.name
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -26,7 +26,7 @@
def render_group_add_href(self, session):
branch = session.branch()
- self.frame().show_broker_group(branch, None).show_add(branch)
+ self.frame.show_broker_group(branch, None).show_add(branch)
return branch.marshal()
class NameColumn(SqlTableColumn):
@@ -130,7 +130,7 @@
class GroupBrokerTab(BrokerSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, group):
return "Brokers %s" % \
@@ -154,15 +154,15 @@
def init(self):
super(BrokerGroupForm, self).init()
- self.group_name.set_object_attr(self.frame().get_object_parameter())
+ self.group_name.set_object_attr(self.frame.get_object_parameter())
class BrokerGroupAdd(BrokerGroupForm):
def process_cancel(self, session):
branch = session.branch()
- self.page().pop_current_frame(branch)
- self.page().pop_current_frame(branch)
- self.page().get_current_frame(branch).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.pop_current_frame(branch)
+ self.page.pop_current_frame(branch)
+ self.page.get_current_frame(branch).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session):
errors = self.validate(session)
@@ -181,13 +181,13 @@
class BrokerGroupEdit(BrokerGroupForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, group):
branch = session.branch()
- self.page().pop_current_frame(branch)
- self.page().get_current_frame(branch).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.pop_current_frame(branch)
+ self.page.get_current_frame(branch).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, group):
errors = self.validate(session)
@@ -209,24 +209,24 @@
class BrokerGroupRemove(CuminConfirmForm, Frame):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, group):
branch = session.branch()
- self.frame().show_view(branch)
- self.page().pop_current_frame(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.pop_current_frame(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, group):
method = self.app.model.broker_group.remove
method.invoke(group)
branch = session.branch()
- self.frame().frame().show_view(branch)
- self.page().pop_current_frame(branch)
- self.page().pop_current_frame(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.frame.show_view(branch)
+ self.page.pop_current_frame(branch)
+ self.page.pop_current_frame(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, group):
return "Remove Broker Group '%s'" % group.name
Modified: mgmt/cumin/python/cumin/brokerprofile.py
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/brokerprofile.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -14,7 +14,7 @@
class BrokerProfileSet(SQLObjectItemSet):
def render_profile_add_href(self, session, *args):
branch = session.branch()
- self.page().show_broker_profile_add(branch)
+ self.page.show_broker_profile_add(branch)
return branch.marshal()
def render_title(self, session, *args):
@@ -25,7 +25,7 @@
def render_item_link(self, session, profile):
branch = session.branch()
- self.page().show_broker_profile(branch, profile).show_view(branch)
+ self.page.show_broker_profile(branch, profile).show_view(branch)
return fmt_olink(branch, profile)
class BrokerProfileFrame(CuminFrame):
@@ -69,7 +69,7 @@
class ProfileConfigTab(ConfigPropertySet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def do_get_items(self, session, profile):
return sorted_by(profile.properties)
@@ -82,7 +82,7 @@
super(BrokerProfileView.ProfileBrokerTab, self).__init__(app, name)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, profile):
return "Brokers %s" % fmt_count(len(profile.brokers))
@@ -92,7 +92,7 @@
def render_item_config_href(self, session, broker):
branch = session.branch()
- frame = self.page().show_broker(branch, broker)
+ frame = self.page.show_broker(branch, broker)
frame.show_view(branch).show_config(branch)
return branch.marshal()
@@ -121,8 +121,8 @@
profile.name = self.profile_name.get(session)
branch = session.branch()
- self.page().show_broker_profile(branch, profile).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_broker_profile(branch, profile).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
class BrokerProfileAdd(BrokerProfileForm, Frame):
def render_title(self, session):
@@ -130,8 +130,8 @@
def process_cancel(self, session):
branch = session.branch()
- self.page().show_main(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_main(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session):
profile = BrokerProfile()
@@ -139,12 +139,12 @@
class BrokerProfileEdit(BrokerProfileForm, Frame):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, profile):
branch = session.branch()
self.parent.show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, profile):
self.process_profile(session, profile)
@@ -157,19 +157,19 @@
class BrokerProfileRemove(CuminConfirmForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, profile):
branch = session.branch()
- self.page().show_broker_profile(branch, profile).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_broker_profile(branch, profile).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, profile):
profile.destroySelf()
branch = session.branch()
- self.page().show_main(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_main(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, profile):
return "Remove Broker Profile '%s'" % profile.name
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/client.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -46,7 +46,7 @@
self.add_child(self.__close)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def get_unit_plural(self, session):
return self.unit.get(session) == "b" and "Bytes" or
"Frames"
@@ -72,9 +72,9 @@
self.parent.ids.clear(session)
branch = session.branch()
- frame = self.frame().show_clients_close(branch)
+ frame = self.frame.show_clients_close(branch)
frame.ids.set(branch, ids)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.set_redirect_url(session, branch.marshal())
class AddressColumn(SqlTableColumn):
def render_title(self, session, data):
@@ -83,7 +83,7 @@
def render_content(self, session, data):
client = Identifiable(data["id"])
branch = session.branch()
- self.frame().show_client(branch, client).show_view(branch)
+ self.frame.show_client(branch, client).show_view(branch)
return fmt_olink(branch, client, name=data["addr"])
class SessionsColumn(SqlTableColumn):
@@ -93,7 +93,7 @@
def render_content(self, session, data):
client = Identifiable(data["id"])
branch = session.branch()
- frame = self.frame().show_client(branch, client)
+ frame = self.frame.show_client(branch, client)
frame.show_view(branch).show_sessions(branch)
# XXX client.sessions won't work
#return fmt_link(branch.marshal(), client.sessions.count())
@@ -161,12 +161,12 @@
class ClientClose(CuminConfirmForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, client):
branch = session.branch()
- self.frame().show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, client):
try:
@@ -188,10 +188,9 @@
class ClientSetClose(CuminBulkActionForm):
def process_return(self, session):
branch = session.branch()
- frame = self.frame()
- frame.show_view(branch)
- self.page().set_current_frame(branch, frame)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.set_current_frame(branch, self.frame)
+ self.page.set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
client = Client.get(id)
@@ -296,10 +295,9 @@
class ClientSessionSetDetach(CuminBulkActionForm, Frame):
def process_return(self, session):
branch = session.branch()
- frame = self.frame()
- frame.show_view(branch).show_sessions(branch)
- self.page().set_current_frame(branch, frame)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch).show_sessions(branch)
+ self.page.set_current_frame(branch, self.frame)
+ self.page.set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
session_ = Session.get(id)
@@ -315,10 +313,9 @@
class ClientSessionSetClose(CuminBulkActionForm, Frame):
def process_return(self, session):
branch = session.branch()
- frame = self.frame()
- frame.show_view(branch).show_sessions(branch)
- self.page().set_current_frame(branch, frame)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch).show_sessions(branch)
+ self.page.set_current_frame(branch, self.frame)
+ self.page.set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
session_ = Session.get(id)
@@ -359,7 +356,7 @@
self.add_child(self.__close)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, client):
return "Sessions %s" % fmt_count(client.sessions.count())
@@ -382,10 +379,10 @@
self.parent.ids.clear(session)
branch = session.branch()
- frame = self.frame().show_sessions_detach(branch)
+ frame = self.frame.show_sessions_detach(branch)
frame.ids.set(branch, ids)
- self.page().set_current_frame(branch, frame)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.set_current_frame(branch, frame)
+ self.page.set_redirect_url(session, branch.marshal())
class Close(FormButton):
def render_content(self, session):
@@ -396,10 +393,10 @@
self.parent.ids.clear(session)
branch = session.branch()
- frame = self.frame().show_sessions_close(branch)
+ frame = self.frame.show_sessions_close(branch)
frame.ids.set(branch, ids)
- self.page().set_current_frame(branch, frame)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.set_current_frame(branch, frame)
+ self.page.set_redirect_url(session, branch.marshal())
class NameColumn(SqlTableColumn):
def render_title(self, session, data):
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/exchange.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -66,7 +66,7 @@
self.add_child(self.phase)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, vhost):
return "Exchanges %s" % fmt_count(vhost.exchanges.count())
@@ -87,7 +87,7 @@
def render_content(self, session, data):
exchange = Identifiable(data["id"])
branch = session.branch()
- self.frame().show_exchange(branch, exchange).show_view(branch)
+ self.frame.show_exchange(branch, exchange).show_view(branch)
name = data["name"] or "<em>Default</em>"
return fmt_olink(branch, exchange, name=name)
@@ -101,7 +101,7 @@
# Restore later
exchange = Identifiable(data["id"])
branch = session.branch()
- frame = self.frame().show_exchange(branch, exchange)
+ frame = self.frame.show_exchange(branch, exchange)
frame.show_view(branch).show_producers(branch)
return fmt_link(branch.marshal(), data["producers"])
@@ -112,7 +112,7 @@
def render_content(self, session, data):
exchange = Identifiable(data["id"])
branch = session.branch()
- frame = self.frame().show_exchange(branch, exchange)
+ frame = self.frame.show_exchange(branch, exchange)
frame.show_view(branch).show_bindings(branch)
return fmt_link(branch.marshal(), data["bindings"])
@@ -235,7 +235,7 @@
class ExchangeBindingSet(BindingSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, exchange):
return "Queue Bindings %s" % \
@@ -250,7 +250,7 @@
def render_item_href(self, session, binding):
branch = session.branch()
- self.frame().frame().show_queue(branch, binding.queue)
+ self.frame.frame.show_queue(branch, binding.queue)
return branch.marshal()
def render_item_name(self, session, binding):
@@ -302,12 +302,12 @@
class ExchangeAdd(ExchangeForm):
def get_args(self, session):
- return self.frame().frame().get_args(session)
+ return self.frame.frame.get_args(session)
def process_cancel(self, session, vhost):
branch = session.branch()
- self.page().show_broker(branch, vhost.get_broker()).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_broker(branch, vhost.get_broker()).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, vhost):
if self.validate(session):
@@ -318,20 +318,20 @@
vhost.addExchange(exchange)
branch = session.branch()
- self.page().show_exchange(branch, exchange).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_exchange(branch, exchange).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, vhost):
return "Add Exchange"
class ExchangeEdit(ExchangeForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, exchange):
branch = session.branch()
- self.page().show_exchange(branch, exchange).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_exchange(branch, exchange).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, exchange):
if self.validate(session):
@@ -353,11 +353,11 @@
class ExchangeRemove(CuminConfirmForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, exchange):
branch = session.branch()
- self.page().show_exchange(branch, exchange).show_view(branch)
+ self.page.show_exchange(branch, exchange).show_view(branch)
session.set_redirect(branch.marshal())
def process_submit(self, session, exchange):
@@ -366,8 +366,8 @@
exchange.remove()
branch = session.branch()
- self.page().show_broker(branch, vhost.get_broker()).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_broker(branch, vhost.get_broker()).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def render_title(self, session, exchange):
return "Remove Exchange '%s'" % exchange.name
@@ -386,7 +386,7 @@
self.add_tab(self.StatisticsHistory(app, "history"))
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, exchange):
return "Statistics"
@@ -399,7 +399,7 @@
self.add_child(StatSet(app, "general", "general"))
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, exchange):
return "Current"
@@ -424,14 +424,14 @@
self.add_child(chart)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, exchange):
return "History"
class ExchangeProducerSet(ItemSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, exchange):
return "Producers %s" % \
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/page.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -111,7 +111,7 @@
self.__object.set(session, object)
writer = Writer()
- for frame in self.page().get_frames(session):
+ for frame in self.page.get_frames(session):
self.__frame_tmpl.render(writer, session, frame)
return writer.to_string()
@@ -138,35 +138,35 @@
def show_broker(self, session, broker):
frame = self.show_mode(session, self.__broker)
frame.set_object(session, broker)
- return self.page().set_current_frame(session, frame)
+ return self.page.set_current_frame(session, frame)
def show_brokers_add(self, session):
frame = self.show_mode(session, self.__brokers_add)
- return self.page().set_current_frame(session, frame)
+ return self.page.set_current_frame(session, frame)
def show_brokers_remove(self, session):
frame = self.show_mode(session, self.__brokers_remove)
- return self.page().set_current_frame(session, frame)
+ return self.page.set_current_frame(session, frame)
def show_broker_group(self, session, group):
frame = self.show_mode(session, self.__group)
frame.set_object(session, group)
- return self.page().set_current_frame(session, frame)
+ return self.page.set_current_frame(session, frame)
def show_broker_profile(self, session, profile):
frame = self.show_mode(session, self.__profile)
frame.set_object(session, profile)
- return self.page().set_current_frame(session, frame)
+ return self.page.set_current_frame(session, frame)
def show_broker_cluster(self, session, cluster):
frame = self.show_mode(session, self.__cluster)
frame.set_object(session, cluster)
- return self.page().set_current_frame(session, frame)
+ return self.page.set_current_frame(session, frame)
def show_system(self, session, system):
frame = self.show_mode(session, self.__system)
frame.set_object(session, system)
- return self.page().set_current_frame(session, frame)
+ return self.page.set_current_frame(session, frame)
def do_process(self, session, *args):
if self.__logout.get(session):
@@ -189,7 +189,7 @@
# lastLoggedOut and lastChallenged
sleep(1)
- self.page().set_redirect_url(session, session.marshal())
+ self.page.set_redirect_url(session, session.marshal())
super(MainFrame, self).do_process(session, *args)
@@ -218,7 +218,7 @@
def edit_session(self, session):
self.parent.selection.set(session, self.name)
- frame = self.page().show_main(session).show_view(session)
+ frame = self.page.show_main(session).show_view(session)
frame.show_messaging(session)
class GridTab(Tab):
@@ -227,7 +227,7 @@
def edit_session(self, session):
self.parent.selection.set(session, self.name)
- frame = self.page().show_main(session).show_view(session)
+ frame = self.page.show_main(session).show_view(session)
frame.show_grid(session)
class SystemsTab(Tab):
@@ -236,7 +236,7 @@
def edit_session(self, session):
self.parent.selection.set(session, self.name)
- frame = self.page().show_main(session).show_view(session)
+ frame = self.page.show_main(session).show_view(session)
frame.show_systems(session)
class MainView(ModeSet):
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/queue.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -61,7 +61,7 @@
self.add_child(self.__purge)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, *args):
return "Queues %s" % fmt_count(Queue.select().count())
@@ -81,9 +81,9 @@
self.parent.ids.clear(session)
branch = session.branch()
- frame = self.frame().show_queues_purge(branch)
+ frame = self.frame.show_queues_purge(branch)
frame.ids.set(branch, ids)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.set_redirect_url(session, branch.marshal())
def render_content(self, session):
return "Purge"
@@ -95,7 +95,7 @@
def render_content(self, session, data):
queue = Identifiable(data["id"])
branch = session.branch()
- self.frame().show_queue(branch, queue).show_view(branch)
+ self.frame.show_queue(branch, queue).show_view(branch)
return fmt_olink(branch, queue, name=data["name"])
class ConsumersColumn(SqlTableColumn):
@@ -108,7 +108,7 @@
# Restore later
queue = Identifiable(data["id"])
branch = session.branch()
- frame = self.frame().show_queue(branch, queue)
+ frame = self.frame.show_queue(branch, queue)
frame.show_view(branch).show_consumers(branch)
return fmt_link(branch.marshal(), data["consumers"])
@@ -119,7 +119,7 @@
def render_content(self, session, data):
queue = Identifiable(data["id"])
branch = session.branch()
- frame = self.frame().show_queue(branch, queue)
+ frame = self.frame.show_queue(branch, queue)
frame.show_view(branch).show_bindings(branch)
return fmt_link(branch.marshal(), data["bindings"])
@@ -277,7 +277,7 @@
class QueueBindingSet(BindingSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, queue):
count = fmt_count(self.get_item_count(session, queue))
@@ -296,7 +296,7 @@
def render_item_href(self, session, binding):
branch = session.branch()
- self.frame().frame().show_exchange(branch, binding.exchange)
+ self.frame.frame.show_exchange(branch, binding.exchange)
return branch.marshal()
def render_item_name(self, session, binding):
@@ -315,10 +315,10 @@
class QueueAdd(QueueForm):
def process_cancel(self, session):
branch = session.branch()
- self.page().pop_current_frame(branch)
- self.page().pop_current_frame(branch)
- self.page().get_current_frame(branch).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.pop_current_frame(branch)
+ self.page.pop_current_frame(branch)
+ self.page.get_current_frame(branch).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session):
errors = self.validate(session)
@@ -326,7 +326,7 @@
if errors:
pass
else:
- reg = self.frame().frame().get_object(session)
+ reg = self.frame.frame.get_object(session)
vhost = reg.getDefaultVhost()
name = self.namef.get(session)
@@ -337,20 +337,20 @@
self.process_cancel(session)
def render_title(self, session):
- reg = self.frame().frame().get_object(session)
+ reg = self.frame.frame.get_object(session)
return "Add Queue to Broker '%s'" % reg.name
class QueuePurge(CuminConfirmForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, queue):
return "Purge Queue '%s'" % queue.name
def process_cancel(self, session, queue):
branch = session.branch()
- self.frame().show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, queue):
action = self.app.model.queue.purge
@@ -367,10 +367,9 @@
class QueueSetPurge(CuminBulkActionForm):
def process_return(self, session):
branch = session.branch()
- frame = self.frame()
- frame.show_view(branch)
- self.page().set_current_frame(branch, frame)
- self.page().set_redirect_url(session, branch.marshal())
+ self.frame.show_view(branch)
+ self.page.set_current_frame(branch, self.frame)
+ self.page.set_redirect_url(session, branch.marshal())
def process_item(self, session, id):
queue = Queue.get(id)
@@ -394,12 +393,12 @@
self.add_child(self.binding_key)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, queue):
branch = session.branch()
- self.page().show_queue(branch, queue).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_queue(branch, queue).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def validate(self, session):
valid = True
@@ -439,12 +438,12 @@
class QueueBindingRemove(CuminConfirmForm):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def process_cancel(self, session, binding):
branch = session.branch()
- self.page().show_queue(branch, binding.get_queue()).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_queue(branch, binding.get_queue()).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, binding):
log.info("Removing binding %s" % binding)
@@ -504,7 +503,7 @@
class QueueConsumerSet(PaginatedItemSet):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_title(self, session, queue):
count = fmt_count(self.get_item_count(session, queue))
Modified: mgmt/cumin/python/cumin/stat.py
===================================================================
--- mgmt/cumin/python/cumin/stat.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/stat.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -24,7 +24,7 @@
self.add_attribute(self.object);
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def do_get_items(self, session, object):
stats = list()
@@ -49,7 +49,7 @@
#if stat.link_cb:
# branch = session.branch()
- # stat.link_cb(self.page(), branch, object)
+ # stat.link_cb(self.page, branch, object)
# return fmt_link(branch.marshal(), stat.value(object))
#else:
@@ -84,7 +84,7 @@
self.add_child(self.duration)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_href(self, session, object):
params = list()
Modified: mgmt/cumin/python/cumin/system.py
===================================================================
--- mgmt/cumin/python/cumin/system.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/system.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -36,7 +36,7 @@
def render_content(self, session, data):
system = Identifiable(data["id"])
branch = session.branch()
- self.frame().show_system(branch, system).show_view(branch)
+ self.frame.show_system(branch, system).show_view(branch)
return fmt_olink(branch, system, name=data["name"])
class SystemFrame(CuminFrame):
Modified: mgmt/cumin/python/cumin/virtualhost.py
===================================================================
--- mgmt/cumin/python/cumin/virtualhost.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/virtualhost.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -21,7 +21,7 @@
def render_item_link(self, session, vhost):
branch = session.branch()
- self.page().show_virtual_host(branch, vhost).show_view(branch)
+ self.page.show_virtual_host(branch, vhost).show_view(branch)
return fmt_olink(branch, vhost)
class VirtualHostFrame(CuminFrame):
@@ -82,7 +82,7 @@
if broker:
branch = session.branch()
- self.page().show_broker(branch, broker).show_view(branch)
+ self.page.show_broker(branch, broker).show_view(branch)
return fmt_olink(branch, broker)
else:
return fmt_none()
@@ -92,7 +92,7 @@
if cluster:
branch = session.branch()
- self.page().show_broker_cluster(branch, cluster).show_view(branch)
+ self.page.show_broker_cluster(branch, cluster).show_view(branch)
return fmt_olink(branch, cluster)
else:
return fmt_none()
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/cumin/widgets.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -74,27 +74,27 @@
self.show_mode(session, mode)
if isinstance(mode, Frame):
- self.page().set_current_frame(session, mode)
+ self.page.set_current_frame(session, mode)
return mode
def do_process(self, session, *args):
- self.page().get_frames(session).append(self)
+ self.page.get_frames(session).append(self)
super(CuminFrame, self).do_process(session, *args)
def render_href(self, session, *args):
branch = session.branch()
- self.page().set_current_frame(branch, self)
+ self.page.set_current_frame(branch, self)
self.show_view(branch)
return branch.marshal()
class CuminView(Widget):
def get_args(self, session):
- return (self.frame().get_object(session),)
+ return (self.frame.get_object(session),)
def render_title(self, session, *args):
- return self.frame().render_title(session, *args)
+ return self.frame.render_title(session, *args)
def render_edit_href(self, session, *args):
branch = session.branch()
@@ -119,7 +119,7 @@
self.add_child(self.submit)
def do_process(self, session, *args):
- self.page().set_modal(session, True)
+ self.page.set_modal(session, True)
if self.cancel.get(session):
self.cancel.set(session, False)
@@ -212,7 +212,7 @@
class CuminStatus(Widget):
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def render_class(self, session, object):
if hasattr(object, "errors"):
@@ -557,7 +557,7 @@
self.ids.set(session, list())
def do_render(self, session, data):
- name = self.ids.path()
+ name = self.ids.path
id = data[self.name]
attr = id in self.ids.get(session) and "checked=\"checked\""
or ""
t = "<td><input type=\"checkbox\" name=\"%s\"
value=\"%i\" %s/></td>"
@@ -566,10 +566,10 @@
class CheckboxIdColumnHeader(ItemTableColumnHeader):
def render_form_id(self, session, *args):
- return self.column.form.path()
+ return self.column.form.path
def render_elem_name(self, session, *args):
- return self.column.ids.path()
+ return self.column.ids.path
class NameField(StringField):
def __init__(self, app, name, form):
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/wooly/__init__.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -15,36 +15,33 @@
self.name = name
self.widget = None
self.default = None
- self.is_required = True
+ self.required = True
- self.__path = None
+ self.path = None
- def path(self):
- if self.__path == None:
- if not self.widget.parent:
- self.__path = self.name
- else:
- self.__path = self.widget.path() + "." + self.name
+ def init(self):
+ if self.widget.path:
+ self.path = ".".join((self.widget.path, self.name))
+ else:
+ self.path = self.name
- return self.__path
+ def set_required(self, required):
+ self.required = required
- def set_required(self, is_required):
- self.is_required = is_required
-
def validate(self, session):
value = self.get(session)
- if value == None and self.is_required:
+ if value is None and self.required:
raise Exception("%s not set" % self)
def get(self, session):
- value = session.get(self.path())
+ value = session.get(self.path)
# Use strict test because empty collections are False
- if value == None:
+ if value is None:
default = self.get_default(session)
- if default != None:
+ if default is not None:
value = self.set(session, default)
return value
@@ -53,7 +50,7 @@
self.set(session, value)
def set(self, session, value):
- return session.set(self.path(), value)
+ return session.set(self.path, value)
def get_default(self, session):
return self.default
@@ -62,7 +59,7 @@
self.default = default
def __repr__(self):
- return "%s('%s')" % (self.__class__.__name__, self.path())
+ return "%s('%s')" % (self.__class__.__name__, self.path)
class Parameter(Attribute):
def __init__(self, app, name):
@@ -95,19 +92,21 @@
self.name = name
self.parent = None
self.children = list()
+ self.children_by_name = dict()
self.attributes = list()
self.parameters = list()
+ # XXX get rid of this
self.html_class = None
+ # These are set in the init() pass
+ self.ancestors = None
+ self.path = None
+ self.page = None
+ self.frame = None
+
self.__main_tmpl = Template(self, "html")
- self.__ancestors = None
- self.__path = None
- self.__page = None
- self.__frame = None
- self.__child_index = None
-
app.add_widget(self)
for cls in self.__class__.__mro__:
@@ -115,73 +114,59 @@
if cls is Widget:
break
+ self.sealed = False
+
def init(self):
- for child in self.children:
- child.init()
+ assert not self.sealed
- def ancestors(self):
- if self.__ancestors is None:
- if self.parent is None:
- self.__ancestors = tuple()
- else:
- ancs = list(self.parent.ancestors())
- ancs.append(self.parent)
+ ancestors = list()
+ widget = self.parent
- self.__ancestors = tuple(ancs)
+ while widget is not None:
+ ancestors.append(widget)
+ widget = widget.parent
- return self.__ancestors
+ for widget in ancestors:
+ if isinstance(widget, Frame):
+ self.frame = widget
+ break
- def path(self):
- if self.__path is None:
- if self.parent is None:
- self.__path = ""
- elif self.parent.parent is None:
- self.__path = self.name;
- else:
- self.__path = self.parent.path() + "." + self.name
+ self.ancestors = tuple(reversed(ancestors))
+
+ pelems = [x.name for x in self.ancestors]
+ pelems.append(self.name)
+ self.path = ".".join(pelems[1:])
- return self.__path
+ assert isinstance(self.ancestors[0], Page)
+ self.page = self.ancestors[0]
- def page(self):
- if self.__page is None:
- if self.parent is None:
- self.__page = self
- else:
- self.__page = self.parent.page()
+ self.sealed = True
- return self.__page
+ self.init_children()
- def frame(self):
- if self.__frame is None:
- if self.parent is None:
- assert isinstance(self, Page)
+ def init_children(self):
+ for attr in self.attributes:
+ attr.init()
- self.__frame = self
- else:
- for anc in self.ancestors():
- if isinstance(anc, Frame):
- self.__frame = anc
-
- return self.__frame
+ for param in self.parameters:
+ param.init()
- def add_child(self, widget):
- self.children.append(widget)
- widget.parent = self
+ for child in self.children:
+ child.init()
- def get_child(self, name):
- if not self.__child_index:
- self.__child_index = dict()
+ def add_child(self, child):
+ assert not self.sealed
+ self.children.append(child)
+ self.children_by_name[child.name] = child
+ child.parent = self
- for child in self.children:
- self.__child_index[child.name] = child
-
- return self.__child_index.get(name, None)
-
def add_attribute(self, attribute):
+ assert not self.sealed
self.attributes.append(attribute)
attribute.widget = self
def add_parameter(self, parameter):
+ assert not self.sealed
self.parameters.append(parameter)
parameter.widget = self
@@ -206,17 +191,12 @@
if str:
return str
- def get_saved_parameters(self, session):
- params = list()
+ def save_parameters(self, session, params):
params.extend(self.parameters)
for child in self.children:
- cparams = child.get_saved_parameters(session)
- if cparams:
- params.extend(cparams)
+ child.save_parameters(session, params)
- return params
-
def get_args(self, session):
return ()
@@ -256,7 +236,7 @@
return writer.to_string()
def render_id(self, session, *args):
- return self.path()
+ return self.path
def render_class(self, session, *args):
return self.html_class
@@ -282,14 +262,14 @@
print " %-30s %s" % (key + ":", value)
def __repr__(self):
- return "%s('%s')" % (self.__class__.__name__, self.path())
+ return "%s('%s')" % (self.__class__.__name__, self.path)
class Frame(Widget):
- def get_saved_parameters(self, session):
- frame = self.page().get_current_frame(session)
+ def save_parameters(self, session, params):
+ frame = self.page.get_current_frame(session)
- if self is frame or self in frame.ancestors():
- return super(Frame, self).get_saved_parameters(session)
+ if self is frame or self in frame.ancestors:
+ super(Frame, self).save_parameters(session, params)
class Page(Frame):
xml_content_type = "text/xml"
@@ -304,12 +284,25 @@
self.redirect = Attribute(app, "redirect")
self.add_attribute(self.redirect)
- self.frame = self.FrameParameter(app, "frame")
- self.add_parameter(self.frame)
+ self.current_frame = self.FrameParameter(app, "frame")
+ self.add_parameter(self.current_frame)
self.set_default_frame(self)
- self.cached_parameters = dict()
+ self.__saved_params = dict()
+ def init(self):
+ assert not self.sealed
+ assert self.parent is None
+
+ self.ancestors = ()
+ self.path = ""
+ self.page = self
+ self.frame = self
+
+ self.sealed = True
+
+ self.init_children()
+
def get_last_modified(self, session):
return datetime.utcnow()
@@ -332,22 +325,19 @@
# XXX take "current" out of these
def set_current_frame(self, session, frame):
- self.frame.set(session, frame)
-
+ self.current_frame.set(session, frame)
return frame
def get_current_frame(self, session):
- return self.frame.get(session)
+ return self.current_frame.get(session)
def pop_current_frame(self, session):
frame = self.get_current_frame(session)
-
#print "Popping current frame", frame
+ return self.set_current_frame(session, frame.frame)
- return self.set_current_frame(session, frame.frame())
-
def set_default_frame(self, frame):
- self.frame.default = frame
+ self.current_frame.default = frame
def get_saved_parameters(self, session):
"""
@@ -359,18 +349,21 @@
preserve the state of parameters in the current frame and all
of its ancestor frames.
"""
-
+
frame = self.get_current_frame(session)
- if frame not in self.cached_parameters:
- params = super(Page, self).get_saved_parameters(session)
- self.cached_parameters[frame] = params
-
- return self.cached_parameters[frame]
+ try:
+ params = self.__saved_params[frame]
+ except KeyError:
+ params = list()
+ self.save_parameters(session, params)
+ self.__saved_params[frame] = params
+ return params
+
class FrameParameter(Parameter):
def do_marshal(self, frame):
- return frame.path()
+ return frame.path
def do_unmarshal(self, path):
return self.app.get_widget(path)
@@ -431,7 +424,7 @@
index = dict()
for widget in self.widgets:
- index[widget.path()] = widget
+ index[widget.path] = widget
self.widget_index = index
@@ -449,7 +442,7 @@
for param in self.parameters:
if param.widget:
- index[(param.widget.page(), param.path())] = param
+ index[(param.widget.page, param.path)] = param
self.parameter_index = index
@@ -553,7 +546,7 @@
vars = list()
for param in params:
- key = param.path()
+ key = param.path
if param.is_collection:
collection = self.get(key)
@@ -715,7 +708,7 @@
if method:
fragments.append(method)
else:
- child = self.widget.get_child(key)
+ child = self.widget.children_by_name.get(key)
if child:
fragments.append(child)
@@ -806,17 +799,3 @@
for call in self.callees:
call.write(writer)
-
-class ArgsDict(dict):
- def __init__(self, parent):
- super(ArgsDict, self).__init__()
-
- self.__parent = parent
-
- def __getitem__(self, key):
- value = super(ArgsDict, self).__getitem__(key)
-
- if value is None and self.__parent:
- value = self.__parent.__getitem__(key)
-
- return value
Modified: mgmt/cumin/python/wooly/forms.py
===================================================================
--- mgmt/cumin/python/wooly/forms.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/wooly/forms.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -21,7 +21,7 @@
params.difference_update(self.form_params)
for param in params:
- key = param.path()
+ key = param.path
if param.is_collection:
collection = session.get(key)
@@ -83,7 +83,7 @@
self.disabled = disabled
def render_name(self, session, *args):
- return self.param.path()
+ return self.param.path
def render_value(self, session, *args):
return self.param.marshal(self.param.get(session))
Modified: mgmt/cumin/python/wooly/parameters.py
===================================================================
--- mgmt/cumin/python/wooly/parameters.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/wooly/parameters.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -49,10 +49,10 @@
raise Exception("Unsupported operation")
def get(self, session):
- return self.path() in session.values
+ return self.path in session.values
def set(self, session, value):
- key = self.path()
+ key = self.path
if value:
session.set(key, None)
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/cumin/python/wooly/widgets.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -22,7 +22,7 @@
self.mode.default = mode.name
def get_selected_mode(self, session):
- return self.get_child(self.mode.get(session))
+ return self.children_by_name.get(self.mode.get(session))
def set_selected_mode(self, session, mode):
self.mode.set(session, mode.name)
Modified: mgmt/misc/boneyard.py
===================================================================
--- mgmt/misc/boneyard.py 2008-03-26 18:38:46 UTC (rev 1799)
+++ mgmt/misc/boneyard.py 2008-03-27 04:49:04 UTC (rev 1800)
@@ -12,7 +12,7 @@
self.add_child(self.servers)
def get_args(self, session):
- return self.frame().get_args(session)
+ return self.frame.get_args(session)
def get_object(self, session):
return self.param.get(session)
@@ -32,13 +32,13 @@
def render_add_group_href(self, session, group):
branch = session.branch()
- self.page().show_server_group_add(branch)
+ self.page.show_server_group_add(branch)
return branch.marshal()
def render_edit_group_href(self, session, group):
if group:
branch = session.branch()
- self.page().show_server_group_edit(branch, group)
+ self.page.show_server_group_edit(branch, group)
return branch.marshal()
def render_remove_group_href(self, session, group):
@@ -115,13 +115,13 @@
def render_add_cluster_href(self, session, cluster):
branch = session.branch()
- #self.page().show_cluster_add(branch)
+ #self.page.show_cluster_add(branch)
return branch.marshal()
def render_edit_cluster_href(self, session, cluster):
if cluster:
branch = session.branch()
- #self.page().show_cluster_edit(branch, cluster)
+ #self.page.show_cluster_edit(branch, cluster)
return branch.marshal()
def render_remove_cluster_href(self, session, cluster):
@@ -190,8 +190,8 @@
def process_cancel(self, session, prop):
branch = session.branch()
- self.page().show_broker(branch, prop.get_broker()).show_view(branch)
- self.page().set_redirect_url(session, branch.marshal())
+ self.page.show_broker(branch, prop.get_broker()).show_view(branch)
+ self.page.set_redirect_url(session, branch.marshal())
def process_submit(self, session, prop):
source = self.source.get(session)
@@ -235,7 +235,7 @@
def render_item_edit_href(self, session, prop):
branch = session.branch()
- frame = self.page().show_broker(branch, prop.get_broker())
+ frame = self.page.show_broker(branch, prop.get_broker())
frame.show_config_property(branch, prop)
return branch.marshal()