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

Error when exporting Worksheets list with senaite.exporter #825

Merged
merged 2 commits into from
May 21, 2018

Conversation

xispa
Copy link
Member

@xispa xispa commented May 19, 2018

Description of the issue/feature this PR addresses

senaite.exporter directly calls to filderitems function from the view that implements BikaListing. Thus, if some variables that haven't been initialized before are useed there, a Traceback is rised.

As a good practice, class variables should always be initialized in the class constructor init, and this commit does it. As a colateral effect, exporter works without rising any error.

Current behavior before PR

The following Trace is rised:

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 senaite.exporter.list_exporters, line 48, in __call__
  Module senaite.exporter.list_exporters, line 131, in export_to_list
  Module senaite.exporter.list_exporters, line 152, in get_items
  Module bika.lims.browser.worksheet.views.folder, line 326, in folderitems
  Module bika.lims.browser.bika_listing, line 932, in folderitems
  Module bika.lims.browser.worksheet.views.folder, line 255, in isItemAllowed
AttributeError: 'FolderView' object has no attribute 'selected_state'

Desired behavior after PR is merged

The list of worksheets gets exported without errors

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

`senaite.exporter` directly calls to filderitems function from the view
that implements BikaListing. Thus, if some variables that haven't been
initialized before are useed there, a Traceback is rised:

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 senaite.exporter.list_exporters, line 48, in __call__
  Module senaite.exporter.list_exporters, line 131, in export_to_list
  Module senaite.exporter.list_exporters, line 152, in get_items
  Module bika.lims.browser.worksheet.views.folder, line 326, in folderitems
  Module bika.lims.browser.bika_listing, line 932, in folderitems
  Module bika.lims.browser.worksheet.views.folder, line 255, in isItemAllowed
AttributeError: 'FolderView' object has no attribute 'selected_state'

As a good practice, class variables should always be initialized in the
class constructor __init__, and this commit does it. As a colateral
effect, exporter works without rising any error.
@ramonski ramonski self-requested a review May 21, 2018 09:43
Copy link
Contributor

@ramonski ramonski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Used variables should always be initialized in the Class' __init__ method and not introduced somewhere in between as a side effect of some method call... Thanks for the correction.

@ramonski ramonski merged commit f1557eb into master May 21, 2018
@xispa xispa deleted the error-export-ws branch June 29, 2018 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants