added as_table option to msgprint

This commit is contained in:
Rushabh Mehta 2011-08-30 13:24:16 +05:30
parent 3122251c3f
commit 87fad95d4b

View file

@ -94,10 +94,13 @@ def errprint(msg):
"""
debug_log.append(cstr(msg or ''))
def msgprint(msg, small=0, raise_exception=0):
def msgprint(msg, small=0, raise_exception=0, as_table=False):
"""
Append to the :data:`message_log`
"""
if as_table and type(msg) in (list, tuple):
msg = '<table border="1px" style="border-collapse: collapse" cellpadding="2px">' + ''.join(['<tr>'+''.join(['<td>%s</td>' % c for c in r])+'</tr>' for r in msg]) + '</table>'
message_log.append((small and '__small:' or '')+cstr(msg or ''))
if raise_exception:
raise ValidationError