Author: justi9
Date: 2008-01-29 16:00:40 -0500 (Tue, 29 Jan 2008)
New Revision: 1624
Modified:
mgmt/cumin/python/wooly/__init__.py
Log:
Adds repr methods to widget objects, and adds a show method to display
object state, to aid debugging.
Modified: mgmt/cumin/python/wooly/__init__.py
===================================================================
--- mgmt/cumin/python/wooly/__init__.py 2008-01-29 19:54:09 UTC (rev 1623)
+++ mgmt/cumin/python/wooly/__init__.py 2008-01-29 21:00:40 UTC (rev 1624)
@@ -35,7 +35,7 @@
value = self.get(session)
if value == None and self.is_required:
- raise Exception("%s not set" % str(self))
+ raise Exception("%s not set" % self)
def get(self, session):
value = session.get(self.path())
@@ -61,8 +61,8 @@
def set_default(self, default):
self.default = default
- def __str__(self):
- return "%s '%s'" % (self.__class__.__name__, self.path())
+ def __repr__(self):
+ return "%s('%s')" % (self.__class__.__name__, self.path())
class Parameter(Attribute):
def __init__(self, app, name):
@@ -308,9 +308,15 @@
def render_error_message(self, session, error):
return error.message
- def __str__(self):
- return "%s '%s'" % (self.__class__.__name__, self.path())
+ def show(self):
+ print self
+ for key, value in sorted(self.__dict__.items()):
+ print " %-25s %s" % (key + ":", value)
+
+ def __repr__(self):
+ return "%s('%s')" % (self.__class__.__name__, self.path())
+
class Frame(Widget):
def get_saved_parameters(self, session):
frame = self.page().get_current_frame(session)
@@ -475,6 +481,9 @@
def get_resource(self, name):
return self.finder.find(name)
+ def __repr__(self):
+ return "%s(default_page=%s)" % (self.__class__.__name__,
self.default_page)
+
class Session(object):
def __init__(self, app, trunk=None):
self.app = app
@@ -624,6 +633,10 @@
except ValueError:
pass
+ def __repr__(self):
+ return "%s(trunk=%s,app=%s)" % \
+ (self.__class__.__name__, self.trunk, self.app)
+
class StringIOWriter(object):
def __init__(self):
self.writer = StringIO()
@@ -754,6 +767,10 @@
if result is not None:
writer.write(str(result))
+ def __repr__(self):
+ name = self.widget.__class__.__name__ + "." + self.key
+ return "%s('%s')" % (self.__class__.__name__, name)
+
class WidgetCall(object):
def __init__(self, stack, widget, session, object):
self.stack = stack
Show replies by date