summaryrefslogtreecommitdiff
path: root/Mailman/htmlformat.py
diff options
context:
space:
mode:
authorklm1998-04-09 22:25:26 +0000
committerklm1998-04-09 22:25:26 +0000
commit33561b12d590d3c37aad7c0536af4c27d6ef45d7 (patch)
tree7daa16247c0d1bbc1ca6953ccc1735b0a56196d9 /Mailman/htmlformat.py
parent0699bfab5b0b40038ae74074cd84013b7e7d459d (diff)
downloadmailman-33561b12d590d3c37aad7c0536af4c27d6ef45d7.tar.gz
mailman-33561b12d590d3c37aad7c0536af4c27d6ef45d7.tar.zst
mailman-33561b12d590d3c37aad7c0536af4c27d6ef45d7.zip
HTMLFormatObject(): Ok, here's a stab at making the error-protection a
bit more specific and unobtrusive. Instead of using a bare except to just silently ignore all encompassed formatting bugs, invoke .Format() only for items that hasattr identifies as having the method. For any other items, return the string representation of the item. This way, python objects that are mistakenly expected to behave like containers or whatever will be presented as the python objects they are - making it easier to track down the error, without crashing the presentation process as a whole. Moreover, it may be a non-error - any object with a string representation can be put in an htmlformat container, and show through.
Diffstat (limited to 'Mailman/htmlformat.py')
-rw-r--r--Mailman/htmlformat.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/Mailman/htmlformat.py b/Mailman/htmlformat.py
index 72a6a53b9..c2e568deb 100644
--- a/Mailman/htmlformat.py
+++ b/Mailman/htmlformat.py
@@ -8,16 +8,13 @@ import string, types
# Format an arbitrary object.
def HTMLFormatObject(item, indent):
-## try:
- if type(item) == type(''):
- return item
- if type(item) == type(2):
- return `item`
-
+ "Return a presentation of an object, invoking their Format method if any."
+ if type(item) == type(''):
+ return item
+ elif not hasattr(item, "Format"):
+ return `item`
+ else:
return item.Format(indent)
-## except:
-## return `item`
-
def CaseInsensitiveKeyedDict(d):
result = {}
@@ -320,9 +317,9 @@ class Form(Container):
class InputObj:
- def __init__(self, name, type, value, checked, **kws):
+ def __init__(self, name, ty, value, checked, **kws):
self.name = name
- self.type = type
+ self.type = ty
self.value = `value`
self.checked = checked
self.kws = kws