Author: justi9
Date: 2007-11-13 12:28:13 -0500 (Tue, 13 Nov 2007)
New Revision: 1300
Modified:
mgmt/cumin/python/cumin/broker.py
mgmt/cumin/python/cumin/brokercluster.py
mgmt/cumin/python/cumin/brokerprofile.py
mgmt/cumin/python/cumin/widgets.py
mgmt/cumin/python/wooly/__init__.py
mgmt/cumin/python/wooly/widgets.py
mgmt/misc/boneyard.py
Log:
Protects the name and parent fields of Widget with __.
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2007-11-13 17:10:06 UTC (rev 1299)
+++ mgmt/cumin/python/cumin/broker.py 2007-11-13 17:28:13 UTC (rev 1300)
@@ -367,9 +367,9 @@
class BrowserBrokers(BrokerSetForm):
def get_items(self, session, model):
brokers = sorted_by(model.get_brokers())
- group = self.parent.group.get(session)
- profile = self.parent.profile.get(session)
- cluster = self.parent.cluster.get(session)
+ group = self.parent().group.get(session)
+ profile = self.parent().profile.get(session)
+ cluster = self.parent().cluster.get(session)
for broker in model.get_brokers():
if group and group not in broker.broker_group_items():
Modified: mgmt/cumin/python/cumin/brokercluster.py
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.py 2007-11-13 17:10:06 UTC (rev 1299)
+++ mgmt/cumin/python/cumin/brokercluster.py 2007-11-13 17:28:13 UTC (rev 1300)
@@ -137,7 +137,7 @@
def process_cancel(self, session, cluster):
branch = session.branch()
- self.parent.show_view(branch)
+ self.parent().show_view(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, cluster):
Modified: mgmt/cumin/python/cumin/brokerprofile.py
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.py 2007-11-13 17:10:06 UTC (rev 1299)
+++ mgmt/cumin/python/cumin/brokerprofile.py 2007-11-13 17:28:13 UTC (rev 1300)
@@ -134,7 +134,7 @@
def process_cancel(self, session, profile):
branch = session.branch()
- self.parent.show_view(branch)
+ self.parent().show_view(branch)
self.page().set_redirect_url(session, branch.marshal())
def process_submit(self, session, profile):
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-11-13 17:10:06 UTC (rev 1299)
+++ mgmt/cumin/python/cumin/widgets.py 2007-11-13 17:28:13 UTC (rev 1300)
@@ -94,11 +94,11 @@
class Cancel(FormButton):
def render_content(self, session, object):
- return self.parent.render_cancel_content(session, object)
+ return self.parent().render_cancel_content(session, object)
class Submit(FormButton):
def render_content(self, session, object):
- return self.parent.render_submit_content(session, object)
+ return self.parent().render_submit_content(session, object)
class CuminConfirmForm(CuminForm):
def __init__(self, app, name):
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2007-11-13 17:10:06 UTC (rev 1299)
+++ mgmt/cumin/python/wooly/__init__.py 2007-11-13 17:28:13 UTC (rev 1300)
@@ -12,8 +12,8 @@
def __init__(self, app, name):
self.app = app
- self.name = name
- self.parent = None
+ self.__name = name
+ self.__parent = None
self.children = list()
self.attributes = list()
self.parameters = list()
@@ -31,13 +31,19 @@
app.add_widget(self)
+ def name(self):
+ return self.__name
+
+ def parent(self):
+ return self.__parent
+
def ancestors(self):
if not self.cached_ancestors:
- if not self.parent:
+ if not self.parent():
self.cached_ancestors = tuple()
else:
- ancs = list(self.parent.ancestors())
- ancs.append(self.parent)
+ ancs = list(self.parent().ancestors())
+ ancs.append(self.parent())
self.cached_ancestors = tuple(ancs)
@@ -45,34 +51,34 @@
def path(self):
if self.cached_path == None:
- if not self.parent:
+ if not self.parent():
self.cached_path = ""
- elif not self.parent.parent:
- self.cached_path = self.name;
+ elif not self.parent().parent():
+ self.cached_path = self.name();
else:
- self.cached_path = self.parent.path() + "." + self.name
+ self.cached_path = self.parent().path() + "." + self.name()
return self.cached_path
def page(self):
if self.cached_page == None:
- if not self.parent:
+ if not self.parent():
self.cached_page = self
else:
- self.cached_page = self.parent.page()
+ self.cached_page = self.parent().page()
return self.cached_page
def add_child(self, widget):
self.children.append(widget)
- widget.parent = self
+ widget.__parent = self
def get_child(self, name):
if not self.child_index:
self.child_index = dict()
for child in self.children:
- self.child_index[child.name] = child
+ self.child_index[child.name()] = child
return self.child_index.get(name, None)
@@ -200,7 +206,7 @@
def path(self):
if self.cached_path == None:
- if not self.widget.parent:
+ if not self.widget.parent():
self.cached_path = self.name
else:
self.cached_path = self.widget.path() + "." + self.name
@@ -377,10 +383,10 @@
self.urls = set()
def add_page(self, page):
- if page.parent:
- raise Exception("Page '%s' is not a root widget" %
page.name)
+ if page.parent():
+ raise Exception("Page '%s' is not a root widget" %
page.name())
- self.pages[page.name] = page
+ self.pages[page.name()] = page
def get_page(self, name):
return self.pages.get(name, self.default_page)
@@ -550,7 +556,7 @@
return url
def marshal_page(self):
- return self.get_page().name
+ return self.get_page().name()
def marshal_url_vars(self, separator=";"):
params = self.get_page().get_saved_parameters(self)
Modified: mgmt/cumin/python/wooly/widgets.py
===================================================================
--- mgmt/cumin/python/wooly/widgets.py 2007-11-13 17:10:06 UTC (rev 1299)
+++ mgmt/cumin/python/wooly/widgets.py 2007-11-13 17:28:13 UTC (rev 1300)
@@ -19,13 +19,13 @@
super(ModeSet, self).add_child(mode)
if not self.mode.default:
- self.mode.set_default(mode.name)
+ self.mode.set_default(mode.name())
def get_selected_mode(self, session):
return self.get_child(self.mode.get(session))
def set_selected_mode(self, session, mode):
- self.mode.set(session, mode.name)
+ self.mode.set(session, mode.name())
def show_mode(self, session, mode):
self.set_selected_mode(session, mode)
Modified: mgmt/misc/boneyard.py
===================================================================
--- mgmt/misc/boneyard.py 2007-11-13 17:10:06 UTC (rev 1299)
+++ mgmt/misc/boneyard.py 2007-11-13 17:28:13 UTC (rev 1300)
@@ -77,9 +77,9 @@
def render_group_link(self, session, group):
branch = session.branch()
- self.parent.param.set(branch, group)
+ self.parent().param.set(branch, group)
- selected = self.parent.param.get(session) is group
+ selected = self.parent().param.get(session) is group
return mlink(branch.marshal(), "ServerGroup", group.name,
selected)