From chrism at plope.com Sun Sep 25 09:44:03 2005 From: chrism at plope.com (Chris McDonough) Date: Sun Aug 10 17:05:20 2008 Subject: [ZPT-CVS] CVS: Products/PageTemplates/tests - testExpressions.py:1.11.44.1 Message-ID: <20050925134403.63D842033E3@mail.zope.org> Update of /cvs-repository/Products/PageTemplates/tests In directory cvs.zope.org:/tmp/cvs-serv24510/lib/python/Products/PageTemplates/tests Modified Files: Tag: Zope-2_7-branch testExpressions.py Log Message: Prevent 'render' function in Expressions.py for being called for basic types (minor speed improvement). See http://www.zope.org/Collectors/Zope/1890. === Products/PageTemplates/tests/testExpressions.py 1.11 => 1.11.44.1 === --- Products/PageTemplates/tests/testExpressions.py:1.11 Thu Sep 26 17:33:17 2002 +++ Products/PageTemplates/tests/testExpressions.py Sun Sep 25 09:44:02 2005 @@ -2,6 +2,11 @@ from Products.PageTemplates import Expressions +class Dummy: + __allow_access_to_unprotected_subobjects__ = 1 + def __call__(self): + return 'dummy' + class ExpressionTests(unittest.TestCase): def setUp(self): @@ -10,6 +15,7 @@ one = 1, d = {'one': 1, 'b': 'b', '': 'blank', '_': 'under'}, blank = '', + dummy = Dummy() ) def tearDown(self): @@ -33,6 +39,10 @@ assert ec.evaluate('one') == 1 assert ec.evaluate('d/one') == 1 assert ec.evaluate('d/b') == 'b' + + def testRenderedEval(self): + ec = self.ec + assert ec.evaluate('dummy') == 'dummy' def testEval1(self): '''Test advanced expression evaluation 1''' From chrism at plope.com Sun Sep 25 09:44:33 2005 From: chrism at plope.com (Chris McDonough) Date: Sun Aug 10 17:05:20 2008 Subject: [ZPT-CVS] CVS: Products/PageTemplates - Expressions.py:1.43.44.6 Message-ID: <20050925134433.14A512033F7@mail.zope.org> Update of /cvs-repository/Products/PageTemplates In directory cvs.zope.org:/tmp/cvs-serv24510/lib/python/Products/PageTemplates Modified Files: Tag: Zope-2_7-branch Expressions.py Log Message: Prevent 'render' function in Expressions.py for being called for basic types (minor speed improvement). See http://www.zope.org/Collectors/Zope/1890. === Products/PageTemplates/Expressions.py 1.43.44.5 => 1.43.44.6 === --- Products/PageTemplates/Expressions.py:1.43.44.5 Fri Mar 25 14:39:03 2005 +++ Products/PageTemplates/Expressions.py Sun Sep 25 09:44:01 2005 @@ -145,7 +145,9 @@ return 0 def _eval(self, econtext, - isinstance=isinstance, StringType=type(''), render=render): + isinstance=isinstance, + BasicTypes=(str, unicode, dict, list, tuple, bool), + render=render): for expr in self._subexprs[:-1]: # Try all but the last subexpression, skipping undefined ones. try: @@ -161,7 +163,7 @@ if self._hybrid: return ob - if self._name == 'nocall' or isinstance(ob, StringType): + if self._name == 'nocall' or isinstance(ob, BasicTypes): return ob # Return the rendered object return render(ob, econtext.vars)