[Zope-dev] Re: [Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PageTemplates/ Merged r68461 from 2.10 branch:

Chris Withers chris at simplistix.co.uk
Mon Jun 5 08:18:32 EDT 2006


Out of interst, why not just make this change wherever empty tales 
expreessions have been used in the past?

It'd be clearer as to what the intention was and remove the necessity 
for hacky code like this...

cheers,

Chris

Florent Guillaume wrote:
> Log message for revision 68462:
>   Merged r68461 from 2.10 branch:
>     Empty TALES path expressions are allowed in Zope 2.
>     http://www.zope.org/Collectors/Zope/2118
>   
> 
> Changed:
>   U   Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
>   U   Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py
> 
> -=-
> Modified: Zope/trunk/lib/python/Products/PageTemplates/Expressions.py
> ===================================================================
> --- Zope/trunk/lib/python/Products/PageTemplates/Expressions.py	2006-06-02 15:02:15 UTC (rev 68461)
> +++ Zope/trunk/lib/python/Products/PageTemplates/Expressions.py	2006-06-02 15:04:12 UTC (rev 68462)
> @@ -99,6 +99,8 @@
>  class ZopePathExpr(PathExpr):
>  
>      def __init__(self, name, expr, engine):
> +        if not expr.strip():
> +            expr = 'nothing'
>          super(ZopePathExpr, self).__init__(name, expr, engine,
>                                             boboAwareZopeTraverse)
>  
> 
> Modified: Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py
> ===================================================================
> --- Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py	2006-06-02 15:02:15 UTC (rev 68461)
> +++ Zope/trunk/lib/python/Products/PageTemplates/tests/testExpressions.py	2006-06-02 15:04:12 UTC (rev 68462)
> @@ -86,6 +86,15 @@
>          self.failUnless(isinstance(defer, DeferWrapper))
>          self.failUnless(isinstance(lazy, LazyWrapper))
>  
> +    def test_empty_ZopePathExpr(self):
> +        """Test empty path expressions.
> +        """
> +        ec = self.ec
> +        self.assertEquals(ec.evaluate('path:'), None)
> +        self.assertEquals(ec.evaluate('path:  '), None)
> +        self.assertEquals(ec.evaluate(''), None)
> +        self.assertEquals(ec.evaluate('  \n'), None)
> +
>  def test_suite():
>      return unittest.makeSuite(ExpressionTests)
>  
> 
> _______________________________________________
> Zope-Checkins maillist  -  Zope-Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/zope-checkins
> 

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the Zope-Dev mailing list