[Zope-Checkins] SVN: Zope/branches/2.12/ Fix bad except clause in the ``sequence_sort`` method of the ``<dtml-in>`` tag.

Tres Seaver tseaver at palladion.com
Sat May 8 01:47:05 EDT 2010


Log message for revision 112186:
  Fix bad except clause in the ``sequence_sort`` method of the ``<dtml-in>`` tag.
  
  LP #267820
  

Changed:
  U   Zope/branches/2.12/doc/CHANGES.rst
  U   Zope/branches/2.12/src/DocumentTemplate/DT_In.py

-=-
Modified: Zope/branches/2.12/doc/CHANGES.rst
===================================================================
--- Zope/branches/2.12/doc/CHANGES.rst	2010-05-08 05:37:42 UTC (rev 112185)
+++ Zope/branches/2.12/doc/CHANGES.rst	2010-05-08 05:47:04 UTC (rev 112186)
@@ -36,6 +36,9 @@
 Bugs Fixed
 ++++++++++
 
+- LP #267820:  Fix bad except clause in the ``sequence_sort`` method of
+  the ``<dtml-in>`` tag.
+
 - LP #351006:  Don't nest block tags inside HTML ``<p>`` tags in
   ``zExceptions.ExceptionFormatter``.
 

Modified: Zope/branches/2.12/src/DocumentTemplate/DT_In.py
===================================================================
--- Zope/branches/2.12/src/DocumentTemplate/DT_In.py	2010-05-08 05:37:42 UTC (rev 112185)
+++ Zope/branches/2.12/src/DocumentTemplate/DT_In.py	2010-05-08 05:47:04 UTC (rev 112186)
@@ -761,19 +761,15 @@
                 if multsort: # More than one sort key.
                     k = []
                     for sk in sortfields:
-                        try:
-                            if mapping: akey = v[sk]
-                            else: akey = getattr(v, sk)
-                        except AttributeError, KeyError: akey = None
+                        if mapping: akey = v.get(sk)
+                        else: akey = getattr(v, sk, None)
                         if not basic_type(akey):
                             try: akey = akey()
                             except: pass
                         k.append(akey)
                 else: # One sort key.
-                    try:
-                        if mapping: k = v[sort]
-                        else: k = getattr(v, sort)
-                    except AttributeError, KeyError: k = None
+                    if mapping: k = v.get(sort)
+                    else: k = getattr(v, sort, None)
                     if not basic_type(type(k)):
                         try: k = k()
                         except: pass



More information about the Zope-Checkins mailing list