Commit 661377e7 authored by Tres Seaver's avatar Tres Seaver

  - Suppress raise of Undefined when the expression is an 'exists:'.

  - Stash referenced object, rather than bound method, as local value
    for iterator.
parent cc8e9a87
...@@ -17,7 +17,7 @@ Page Template-specific implementation of TALES, with handlers ...@@ -17,7 +17,7 @@ Page Template-specific implementation of TALES, with handlers
for Python expressions, string literals, and paths. for Python expressions, string literals, and paths.
""" """
__version__='$Revision: 1.27 $'[11:-2] __version__='$Revision: 1.28 $'[11:-2]
import re, sys import re, sys
from TALES import Engine, CompilerError, _valid_name, NAME_RE, \ from TALES import Engine, CompilerError, _valid_name, NAME_RE, \
...@@ -142,11 +142,11 @@ class PathExpr: ...@@ -142,11 +142,11 @@ class PathExpr:
exists = 1 exists = 1
break break
except Undefined: except Undefined:
if not more_paths: if self._name != 'exists' and not more_paths:
raise raise
except (AttributeError, KeyError, TypeError, IndexError, except (AttributeError, KeyError, TypeError, IndexError,
Unauthorized), e: Unauthorized), e:
if not more_paths: if self._name != 'exists' and not more_paths:
raise Undefined(self._s, sys.exc_info()) raise Undefined(self._s, sys.exc_info())
if self._name == 'exists': if self._name == 'exists':
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
An implementation of a generic TALES engine An implementation of a generic TALES engine
""" """
__version__='$Revision: 1.25 $'[11:-2] __version__='$Revision: 1.26 $'[11:-2]
import re, sys, ZTUtils import re, sys, ZTUtils
from MultiMapping import MultiMapping from MultiMapping import MultiMapping
...@@ -109,7 +109,7 @@ class Iterator(ZTUtils.Iterator): ...@@ -109,7 +109,7 @@ class Iterator(ZTUtils.Iterator):
def next(self): def next(self):
try: try:
if ZTUtils.Iterator.next(self): if ZTUtils.Iterator.next(self):
self._context.setLocal(self.name, self.item) self._context.setLocal(self.name, self.item())
return 1 return 1
except TALESError: except TALESError:
raise raise
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment