[Zope-dev] Possible performance problem in Page Template engine?

Andreas Jung lists at zopyx.com
Sat Oct 27 08:05:32 EDT 2007


--On 27. Oktober 2007 00:33:42 +0200 Christian Scholz <cs at comlounge.net> 
wrote:

> Hi everybody!
>
> When I was trying to fix portlets in Plone I was wondering why the
> render() method of my portlet actually gets called multiple times.
>
> After a bit of investigation I ended up in the Five product in
> browser/providerexpressions.py where provider expressions also seem to be
> called twice for each provider statement.
>
> The problem seems to be in Products/PageTemplates/Expressions.py in line
> 199/200 (in Zope 2.10.4):
>
> def evaluateStructure(self, expr):
>          """ customized version in order to get rid of unicode
>              errors for all and ever
>          """
>          text = super(ZopeContext, self).evaluateStructure(expr)
>          return self._handleText(text, expr)
>
> This construct seems to evaluate expr twice. One time in
> evaluateStructure() of the super class which is basically a call to
> self.evaluate(expr) (to be found in zope/tales/tales.py around line 713:
>
>      def evaluateStructure(self, expr):
>          return self.evaluate(expr)
>
> and then again in _handleText():
>
>      def _handleText(self, text, expr):
>
>          text = self.evaluate(expr)
>
>          ...
>
> I now tried to remove the evaluation of expr in handleText() and in a
> very simple test using ab on my site I got twice the speed!
>

The evaluate() call within _handleText() is a culprit from my refactoring.
However I see this code only on the trunk. It is not contained on the 2.10
branch. Anyway...I removed the culprit from the trunk and everything should 
be fast again.

Andreas

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope-dev/attachments/20071027/6d924d0f/attachment.bin


More information about the Zope-Dev mailing list