Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty datetime field in an EasyForm throws an exception #22

Closed
batlock666 opened this issue Feb 8, 2019 · 1 comment
Closed

Empty datetime field in an EasyForm throws an exception #22

batlock666 opened this issue Feb 8, 2019 · 1 comment

Comments

@batlock666
Copy link
Contributor

batlock666 commented Feb 8, 2019

I created an EasyForm with a single datetime field. This field is not required. When I submit the form with the datetime field left empty, I get the following exception:

Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module plone.z3cform.layout, line 63, in __call__
Module plone.z3cform.layout, line 57, in update
Module z3c.form.form, line 163, in render
Module Products.Five.browser.pagetemplatefile, line 125, in __call__
Module Products.Five.browser.pagetemplatefile, line 59, in __call__
Module zope.pagetemplate.pagetemplate, line 137, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 171, in render
Module aa6bca81f4134407c247edc3cf6064dd.py, line 302, in render
Module five.pt.expressions, line 161, in __call__
Module z3c.form.widget, line 154, in render
Module zope.browserpage.viewpagetemplatefile, line 49, in __call__
Module zope.pagetemplate.pagetemplate, line 137, in pt_render
Module five.pt.engine, line 98, in __call__
Module z3c.pt.pagetemplate, line 163, in render
Module chameleon.zpt.template, line 261, in render
Module chameleon.template, line 191, in render
Module chameleon.template, line 171, in render
Module 98a55ed249bfb07b085d0534cdf2aabe.py, line 151, in render
Module five.pt.expressions, line 154, in __call__
Module five.pt.expressions, line 126, in traverse
Module zope.traversing.adapters, line 142, in traversePathElement
- __traceback_info__: (<DatetimeWidget 'form.widgets.my_datetime'>, 'formatted_value')
Module zope.traversing.adapters, line 42, in traverse
- __traceback_info__: (<DatetimeWidget 'form.widgets.my_datetime'>, 'formatted_value', ())
Module plone.formwidget.datetime.base, line 181, in formatted_value
Module plone.formwidget.datetime.base, line 435, in _dtvalue
Module plone.formwidget.datetime.base, line 292, in _base_dtvalue
ValueError: invalid literal for int() with base 10: ''

- Expression: "w/render"
- Filename:   ... 2.0.1-py2.7.egg/collective/easyform/browser/thank_you.pt
- Location:   (line 21: col 39)
- Source:     <span tal:replace="structure w/render"></span>
                                            ^^^^^^^^
- Expression: "view/formatted_value"
- Filename:   ... py2.7.egg/plone/formwidget/datetime/templates/display.pt
- Location:   (line 6: col 27)
- Source:     ><tal:block condition="view/formatted_value"
                                    ^^^^^^^^^^^^^^^^^^^^
- Arguments:  repeat: {...} (0)
            context: <ImplicitAcquisitionWrapper my-easyform at 0x7f5e8f033d20>
            views: <ViewMapper - at 0x7f5e8d54d910>
            modules: <TraversableModuleImporter - at 0x7f5e9f797510>
            args: <tuple - at 0x7f5ea7f97050>
            nothing: <NoneType - at 0x8f5320>
            target_language: en
            default: <object - at 0x7f5ea7eb7540>
            request: <instance - at 0x7f5e8e996b90>
            wrapped_repeat: {...} (0)
            loop: {...} (0)
            template: <ViewPageTemplateFile - at 0x7f5e9085fdd0>
            translate: <function translate at 0x7f5e8d6f8cf8>
            options: {...} (0)
            view: <DatetimeWidget my_datetime at 0x7f5e8d6f7f90>

From this traceback, it looks like the problem is with plone.formwidget.datetime, and not with collective.easyform.

@batlock666
Copy link
Contributor Author

Inspecting method AbstractDateWidget.formatted_value() shows me the following:

  • self.value=(u'', u'', u'', '00', '00')
  • self.empty_value=('', '', '', '00', '00', '')

The value passed in from the form is not the same as the empty value, even though it should be. The empty value for the timezone is missing.

jensens added a commit that referenced this issue May 21, 2019
Tuple ('', '', '', '00', '00') is also an empty value. Fix #22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant