Author: eallen
Date: 2008-11-05 10:03:33 -0500 (Wed, 05 Nov 2008)
New Revision: 2739
Modified:
mgmt/trunk/cumin/python/cumin/formats.py
Log:
Added fmt_dict global method to display dict() data in model properties.
Modified: mgmt/trunk/cumin/python/cumin/formats.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/formats.py 2008-11-04 21:11:31 UTC (rev 2738)
+++ mgmt/trunk/cumin/python/cumin/formats.py 2008-11-05 15:03:33 UTC (rev 2739)
@@ -2,6 +2,7 @@
from random import random
from util import *
+from wooly import Writer
def fmt_count(count):
return "<span class=\"count\">(%i)</span>" % count
@@ -132,3 +133,21 @@
name = fmt_shorten(name, pre, post)
return fmt_link(session.marshal(), name, selected and "selected")
+
+def fmt_dict(value, prefix=None):
+ html = """
+ <tr style="border-top: 0; border-bottom: 1px dotted #CCCCCC;">
+ <td style="padding:0; color: #444444;"
nowrap="nowrap">%s</td>
+ <td style="padding:0 0 0 1em;">%s</td>
+ </tr>
+ """
+ writer = Writer()
+ writer.write("<table style='border-collapse: collapse;'>")
+ for key in value:
+ show_key = key
+ if prefix:
+ if key.startswith(prefix):
+ show_key = key[len(prefix):]
+ writer.write(html % (show_key, str(value[key])))
+ writer.write("</table>")
+ return writer.to_string()