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

Fix tracbeack on DateOfBirth update while validation fails for others #76

Merged
merged 3 commits into from
May 19, 2023

Conversation

xispa
Copy link
Member

@xispa xispa commented May 19, 2023

Description of the issue/feature this PR addresses

This Pull Request fixes the traceback that arises for AgeDoBWidget when submitting the sample header form and a validator for a field other than DateOfBirth fails.

Current behavior before PR

Traceback (most recent call last):
  File "/home/senaite/buildout-cache/eggs/plone.app.viewletmanager-3.1.3-py2.7.egg/plone/app/viewletmanager/manager.py", line 110, in render
    html.append(viewlet.render())
  File "/home/senaite/zinstance/src/senaite.core/src/senaite/core/browser/viewlets/sampleheader.py", line 64, in render
    return self.template(errors=errors)
  File "/home/senaite/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 126, in __call__
    return self.__func__(__self__, *args, **kw)
  File "/home/senaite/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 61, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File "/home/senaite/buildout-cache/eggs/zope.pagetemplate-4.6.0-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 135, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations
  File "/home/senaite/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/Products/PageTemplates/engine.py", line 378, in __call__
    return template.render(**kwargs)
  File "/home/senaite/buildout-cache/eggs/z3c.pt-3.3.1-py2.7.egg/z3c/pt/pagetemplate.py", line 176, in render
    return base_renderer(**context)
  File "/home/senaite/buildout-cache/eggs/Chameleon-3.9.1-py2.7.egg/chameleon/zpt/template.py", line 302, in render
    return super(PageTemplate, self).render(**_kw)
  File "/home/senaite/buildout-cache/eggs/Chameleon-3.9.1-py2.7.egg/chameleon/template.py", line 215, in render
    raise_with_traceback(exc, tb)
  File "/home/senaite/buildout-cache/eggs/Chameleon-3.9.1-py2.7.egg/chameleon/template.py", line 192, in render
    self._render(stream, econtext, rcontext)
  File "/home/senaite/zinstance/var/my.lims/cache/3b43af95839c40c7434c21391b024f64.py", line 840, in render
    __m(__stream, econtext.copy(), rcontext, __i18n_domain)
  File "/home/senaite/zinstance/var/my.lims/cache/7e99918db1b0c81e3fd3e9de85de5445.py", line 187, in render_edit
    __value = _static_139673307801040('python', u' values[0]', econtext=econtext)(_static_139673307801296(econtext, __zt_tmp))
  File "/home/senaite/buildout-cache/eggs/zope.tales-5.2-py2.7.egg/zope/tales/pythonexpr.py", line 73, in __call__
    return eval(self._code, vars)
  File "<string>", line 1, in <module>
  File "/home/senaite/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/ZPublisher/HTTPRequest.py", line 1798, in __getitem__
    return self.__dict__[key]
KeyError: 0

 - Expression: "dob python: value"
 - Filename:   ... /skins/templates/senaite_patient_widgets/agedobwidget.pt
 - Location:   (line 50: col 26)
 - Source:     dob python: values[0];
               ^^^^^^^^^^^^^^^^^
 - Expression: "python:view.render_widget(field, mode=mode)"
 - Filename:   ... /senaite/core/browser/viewlets/templates/sampleheader.pt
 - Location:   (line 104: col 48)
 - Source:     ... use-macro="python:view.render_widget(field, mode=mode)"/>

Desired behavior after PR is merged

No complains

--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.

```
Traceback (most recent call last):
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/plone.app.viewletmanager-3.1.3-py2.7.egg/plone/app/viewletmanager/manager.py", line 110, in render
    html.append(viewlet.render())
  File "/home/jordi/Desenvolupament/plone5/zinstance/src/senaite.core/src/senaite/core/browser/viewlets/sampleheader.py", line 64, in render
    return self.template(errors=errors)
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 126, in __call__
    return self.__func__(__self__, *args, **kw)
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 61, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/zope.pagetemplate-4.6.0-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 135, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/Products/PageTemplates/engine.py", line 378, in __call__
    return template.render(**kwargs)
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/z3c.pt-3.3.1-py2.7.egg/z3c/pt/pagetemplate.py", line 176, in render
    return base_renderer(**context)
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/Chameleon-3.9.1-py2.7.egg/chameleon/zpt/template.py", line 302, in render
    return super(PageTemplate, self).render(**_kw)
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/Chameleon-3.9.1-py2.7.egg/chameleon/template.py", line 215, in render
    raise_with_traceback(exc, tb)
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/Chameleon-3.9.1-py2.7.egg/chameleon/template.py", line 192, in render
    self._render(stream, econtext, rcontext)
  File "/home/jordi/Desenvolupament/plone5/zinstance/var/png.lims/cache/3b43af95839c40c7434c21391b024f64.py", line 840, in render
    __m(__stream, econtext.copy(), rcontext, __i18n_domain)
  File "/home/jordi/Desenvolupament/plone5/zinstance/var/png.lims/cache/7e99918db1b0c81e3fd3e9de85de5445.py", line 187, in render_edit
    __value = _static_139673307801040('python', u' values[0]', econtext=econtext)(_static_139673307801296(econtext, __zt_tmp))
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/zope.tales-5.2-py2.7.egg/zope/tales/pythonexpr.py", line 73, in __call__
    return eval(self._code, vars)
  File "<string>", line 1, in <module>
  File "/home/jordi/Desenvolupament/plone5/buildout-cache/eggs/Zope-4.8.7-py2.7.egg/ZPublisher/HTTPRequest.py", line 1798, in __getitem__
    return self.__dict__[key]
KeyError: 0

 - Expression: "dob python: value"
 - Filename:   ... /skins/templates/senaite_patient_widgets/agedobwidget.pt
 - Location:   (line 50: col 26)
 - Source:     dob python: values[0];
               ^^^^^^^^^^^^^^^^^
 - Expression: "python:view.render_widget(field, mode=mode)"
 - Filename:   ... /senaite/core/browser/viewlets/templates/sampleheader.pt
 - Location:   (line 104: col 48)
 - Source:     ... use-macro="python:view.render_widget(field, mode=mode)"/>
```
@xispa xispa changed the title Fix traceback when the validator of another field gives error on submit Fix traceback when updating DateOfBirth while the validator of other field fails May 19, 2023
@xispa xispa changed the title Fix traceback when updating DateOfBirth while the validator of other field fails Fix tracbeack on DateOfBirth update while validation fails for others May 19, 2023
@ramonski ramonski merged commit 8145a4b into master May 19, 2023
@ramonski ramonski deleted the fix-agedob-widget-traceback branch May 19, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants