[Mpuls-commits] r2266 - wasko/branches/2.0/mpulsweb/lib/helper
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Apr 1 08:03:01 CEST 2010
Author: torsten
Date: 2010-04-01 08:03:00 +0200 (Thu, 01 Apr 2010)
New Revision: 2266
Modified:
wasko/branches/2.0/mpulsweb/lib/helper/filters.py
Log:
* mpulsweb/lib/helper/filters.py: Only shorten element (text) if it has a
length. Elese return unmodified element. Now ot does not lead into a
traceback if e.g. a date object was provided to tthe function by
accident.
Modified: wasko/branches/2.0/mpulsweb/lib/helper/filters.py
===================================================================
--- wasko/branches/2.0/mpulsweb/lib/helper/filters.py 2010-03-31 15:12:53 UTC (rev 2265)
+++ wasko/branches/2.0/mpulsweb/lib/helper/filters.py 2010-04-01 06:03:00 UTC (rev 2266)
@@ -29,7 +29,10 @@
#
from cgi import escape
+import logging
+log = logging.getLogger(__name__)
+
def no_none(text):
if text == 'None' or not text:
return ''
@@ -45,8 +48,12 @@
def shorten(text, length=40):
shortcut = "..."
- if text and len(text) > length:
- text = text[0:length-len(shortcut)] + shortcut
+ try:
+ len(text)
+ if text and len(text) > length:
+ text = text[0:length-len(shortcut)] + shortcut
+ except:
+ log.warning('Trying to shorten a non string type: %s' % text)
return text
def nl_to_br(text):
More information about the Mpuls-commits
mailing list