Customizing login template in Plone 5.2 via portal_view_customizations causes LocationError

I am encountering an odd behavior after upgrading to Plone 5.2 from Plone 5.1. We had an old login_form customization that was registered TTW with portal_view_customizations. I wanted to carry over the same semantic change to the new login.pt registered as plone.app.layout.navigation.interfaces.inavigationroot-login. The problem is that when I use the ZMI to customize the template, the changes cause a LocationError. Since the customized version was prepopulated, I did not make any changes to the template itself. I used the old one verbatim. I could attempt using jbot, but I would prefer to keep this one TTW.

Thank you anyone for any potential insights!

See the stacktrace below:

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 156, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 338, in publish_module
  Module ZPublisher.WSGIPublisher, line 256, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 62, in call_object
  Module five.customerize.zpt, line 83, in __call__
  Module Products.PageTemplates.ZopePageTemplate, line 284, in _exec
  Module Products.PageTemplates.ZopePageTemplate, line 371, in pt_render
  Module Products.PageTemplates.PageTemplate, line 85, in pt_render
  Module zope.pagetemplate.pagetemplate, line 135, in pt_render
  Module Products.PageTemplates.engine, line 88, in __call__
  Module z3c.pt.pagetemplate, line 173, in render
  Module chameleon.zpt.template, line 306, in render
  Module chameleon.template, line 209, in render
  Module chameleon.template, line 187, in render
  Module 9b10aea4c6009546e1d5e169ad92cd8e.py, line 836, in render
  Module c0b94c59d6b37ccb11da0087ec14b24f.py, line 1028, in render_master
  Module c0b94c59d6b37ccb11da0087ec14b24f.py, line 379, in render_content
  Module 9b10aea4c6009546e1d5e169ad92cd8e.py, line 826, in __fill_main
  Module 9b10aea4c6009546e1d5e169ad92cd8e.py, line 190, in render_main
  Module Products.PageTemplates.expression, line 74, in __call__
  Module Products.PageTemplates.expression, line 65, in traverse
  Module zope.traversing.adapters, line 156, in traversePathElement
   - __traceback_info__: (None, 'values')
  Module zope.traversing.adapters, line 61, in traverse
   - __traceback_info__: (None, 'values', ())
LocationError: (None, 'values')

 - Expression: "view/widgets/values"
 - Filename:   ... e.app.layout.navigation.interfaces.inavigationroot-login
 - Location:   (line 28: col 40)
 - Expression: "here/main_template/macros/master"
 - Filename:   ... e.app.layout.navigation.interfaces.inavigationroot-login
 - Location:   (line 7: col 23)
 - Arguments:  repeat: {...} (0)
               template: <ImplicitAcquisitionWrapper plone.app.layout.navigation.interfaces.inavigationroot-login at 0x7f67fb891cd0>
               modules: <_SecureModuleImporter - at 0x7f68105beed0>
               here: <ImplicitAcquisitionWrapper Plone at 0x7f67eaf89050>
               wrapped_repeat: <SafeMapping - at 0x7f67f8369908>
               user: <ImplicitAcquisitionWrapper - at 0x7f67fb8a3820>
               nothing: <NoneType - at 0x936be0>
               root: <Application  at 0x7f67fb55cc08>
               target_language: <NoneType - at 0x936be0>
               container: <ImplicitAcquisitionWrapper portal_view_customizations at 0x7f67fb8e1820>
               default: <object - at 0x7f68186c1790>
               request: <WSGIRequest - at 0x7f67eafb5e10>
               loop: {...} (0)
               context: <ImplicitAcquisitionWrapper Plone at 0x7f67eaf89050>
               translate: <function translate at 0x7f67eb374668>
               macroname: master
               options: {...} (1)
               view: <TTWView None at 0x7f68102cdfd0>

portal_view_customizations? Why is this still around...this functionality was notoriously broken. Just don't use it. z3c.jbot is your friend.

Thank you for the information, @zopyx. I was not aware that using portal_view_customizations TTW is now considered a risky practice. Using the jbot alternative did work. I also did note that there is a note at the top of the portal_view_customizations registration page that mentions the change in sentiment towards customizing in that way.

The problem is not that it is notoriously broken but that all templates and such that you customize with portal_view_customizations are changed to use RestrictedPython. So a lot of templates that worked fine as a filesystem-template (which use normal Python) are broken after being moved to the Database.
The problem got more severe since Plone 5.2 uses a new version of RestrictedPython which is more restrictive that the version used in 5.1
See https://restrictedpython.readthedocs.io for details.

The solution stays the same: Use z3c.jbot instead

2 Likes

Plone Foundation Code of Conduct