Comment 4 for bug 732972

Revision history for this message
Maurits van Rees (maurits-vanrees) wrote :

4.0.0 has been released on PyPI.

That gives problems when I use it on Plone 4.2 when using Chameleon/five.pt (so not standard Plone out of the box). Some tests go wrong or at least give extra error output. It also happens when as anonymous user you try to view a document that is private. You are redirected to the login page just fine, but in the logs you get an error:

Traceback (most recent call last):
  File "/Users/mauritsvanrees/shared-eggs/zExceptions-2.13.0-py2.7.egg/zExceptions/ExceptionFormatter.py", line 153, in formatLine
    supp = factory(*args)
  File "/Users/mauritsvanrees/community/plone-coredev/4.2/src/zope.pagetemplate/src/zope/pagetemplate/pagetemplate.py", line 265, in __init__
    e = pt.pt_errors(namespace, check_macro_expansion=False)
TypeError: pt_errors() got an unexpected keyword argument 'check_macro_expansion'

You get the same error twice, actually.

The problem is that not all page templates that are passed to the PageTemplateTracebackSupplement are from zope.pagetemplate. In the above case the class of the template is Products.CMFCore.FSPageTemplate.FSPageTemplate.

This simple change in pagetemplate.py would fix it for me:

- e = pt.pt_errors(namespace, check_macro_expansion=False)
+ try:
+ e = pt.pt_errors(namespace, check_macro_expansion=False)
+ except TypeError:
+ # Old page template.
+ e = pt.pt_errors(namespace)

I am not sure if that is the best way to go.
Alternatively, the pt_errors in Zope2/src/Products/PageTemplates/PageTemplate.py could be changed to accept check_macro_expansion as argument (and probably ignore it).