[rhmessaging-commits] rhmessaging commits: r1338 - mgmt/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Nov 19 20:00:40 EST 2007


Author: justi9
Date: 2007-11-19 20:00:40 -0500 (Mon, 19 Nov 2007)
New Revision: 1338

Modified:
   mgmt/cumin/python/cumin/formats.py
Log:
Adds a function to shorten names and uses it in fmt_olink.



Modified: mgmt/cumin/python/cumin/formats.py
===================================================================
--- mgmt/cumin/python/cumin/formats.py	2007-11-19 17:13:30 UTC (rev 1337)
+++ mgmt/cumin/python/cumin/formats.py	2007-11-20 01:00:40 UTC (rev 1338)
@@ -58,11 +58,18 @@
 def fmt_none():
     return "<span class=\"none\">None</span>"
 
+def fmt_shorten(string):
+    if len(string) > 15:
+        return string[:10] + "..." + string[-5:]
+
 def fmt_link(href, content, class_=""):
     return "<a href=\"%s\"%s>%s</a>" % \
            (href, class_ and " class=\"%s\" " % class_ or " ", content)
 
 def fmt_olink(session, object, selected=False, name=None):
-    return fmt_link(session.marshal(),
-                    getattr(object, "name", name),
-                    selected and "selected")
+    n = getattr(object, "name", name)
+
+    if isinstance(n, basestring):
+        n = fmt_shorten(n)
+
+    return fmt_link(session.marshal(), n, selected and "selected")




More information about the rhmessaging-commits mailing list