Plone 5.2.2, Python 3.8.5
Hi, I am trying to write a custom Pagetemplate to edit some fields of a content_type. Therefore I created a subclass from DefaultView
:
from plone.dexterity.browser.view import DefaultView
class UksNew(DefaultView):
def __call__(self):
# Fills the dictionary self.w
self.update()
# Now set the mode of each widget to "input"
for name, widget in self.w.items():
widget.mode = 'input'
return super().__call__()
And in my pt
file I then can write something like this:
<div tal:replace="structure view/w/myCustomField/@@ploneform-render-widget" />
I am not sure if @@ploneform-render-widget
is the right thing here but it works better than the render
method because it also renders the label and validation errors if there are some.
However my main issue is that I am unable to render the title or any other field that comes from a behavior except IShortName.id
. This works:
<div tal:replace="structure view/w/IShortName.id/ploneform-render-widget" />
But this throws an exception:
<div tal:replace="structure view/w/IBasic.title/@@ploneform-render-widget" />
In the exception you can see that only the IShortName.id
widget is available and no other widget from the behaviors I defined for that type:
Traceback (innermost last):
Module ZPublisher.WSGIPublisher, line 162, in transaction_pubevents
Module ZPublisher.WSGIPublisher, line 359, in publish_module
Module ZPublisher.WSGIPublisher, line 254, in publish
Module ZPublisher.mapply, line 85, in mapply
Module ZPublisher.WSGIPublisher, line 63, in call_object
Module ldkiid.gui.browser.uksgui, line 248, in __call__
Module plone.autoform.view, line 42, in __call__
Module plone.autoform.view, line 33, in render
Module Products.Five.browser.pagetemplatefile, line 126, in __call__
Module Products.Five.browser.pagetemplatefile, line 58, in __call__
Module zope.pagetemplate.pagetemplate, line 133, in pt_render
Module Products.PageTemplates.engine, line 367, in __call__
Module z3c.pt.pagetemplate, line 176, in render
Module chameleon.zpt.template, line 307, in render
Module chameleon.template, line 214, in render
Module chameleon.utils, line 75, in raise_with_traceback
Module chameleon.template, line 192, in render
Module fa54e4b1003d1061caf3c68edad839f7, line 756, in render
Module 4029b48a9028ca2f58238d1588b37fc8, line 860, in render_master
Module 4029b48a9028ca2f58238d1588b37fc8, line 1526, in render_content
Module fa54e4b1003d1061caf3c68edad839f7, line 241, in __fill_main
Module zope.tales.expressions, line 250, in __call__
Module Products.PageTemplates.Expressions, line 188, in _eval
Module zope.tales.expressions, line 153, in _eval
Module Products.PageTemplates.Expressions, line 104, in trustedBoboAwareZopeTraverse
Module zope.traversing.adapters, line 156, in traversePathElement
- __traceback_info__: ({'myCustomField': <DateWidget 'form.widgets.myCustomField'>, 'IShortName.id': <TextWidget 'form.widgets.IShortName.id'>}, 'IBasic.title')
Module zope.traversing.adapters, line 61, in traverse
- __traceback_info__: ({'myCustomField': <DateWidget 'form.widgets.myCustomField'>, 'IShortName.id': <TextWidget 'form.widgets.IShortName.id'>}, 'IBasic.title', ['@@ploneform-render-widget'])
zope.location.interfaces.LocationError: zope.location.interfaces.LocationError: ({'myCustomField': <DateWidget 'form.widgets.myCustomField'>, 'IShortName.id': <TextWidget 'form.widgets.IShortName.id'>}, 'IBasic.title')
These are the behaviors I enabled for that type:
<element value="plone.namefromtitle"/>
<element value="plone.excludefromnavigation"/>
<element value="plone.shortname"/>
<element value="plone.ownership"/>
<element value="plone.basic"/>
<element value="plone.locking"/>
What is it that I am missing? How can I populate the view.w
dictionary with all widgets of all behaviors?
Thanks!