Rendering a form fails with "AttributeError: 'str' object has no attribute 'other'"

by David Glick last modified Oct 21, 2009 09:21 AM
This error is a consequence of using Zope 2's ViewPageTemplateFile when Zope 3's is expected.

Zope 2 and Zope 3 each provide their own version of the ViewPageTemplateFile class.

Zope 2 view template
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
Zope 3 view template
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile

When using z3c.form in Plone, the Zope 2 class must be used when overriding the template of a form wrapper, but the Zope 3 class must be used when overriding the template of an actual form.

Otherwise, you'll see a traceback ending something like this:

  Module z3c.form.form, line 156, in render
  Module Shared.DC.Scripts.Bindings, line 313, in __call__
  Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
  Module Shared.DC.Scripts.Bindings, line 1, in ?
  Module Shared.DC.Scripts.Bindings, line 293, in _getTraverseSubpath
AttributeError: 'str' object has no attribute 'other'