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

Traceback on automatic sticker printing in batch context #672

Merged
merged 3 commits into from
Feb 21, 2018

Conversation

xispa
Copy link
Member

@xispa xispa commented Feb 20, 2018

Description of the issue/feature this PR addresses

Traceback on rendering stickers from inside batch context on AR receive.

Linked issue: #671

Current behavior before PR

The following traceback appears in stickers preview:

Traceback (most recent call last):
  File "/home/xispa/zinstance/src/senaite.core/bika/lims/browser/stickers.py", line 295, in renderItem
    return embed(self)
  File "/home/xispa/buildout-cache/eggs/Zope2-2.13.26-py2.7.egg/Products/Five/browser/pagetemplatefile.py", line 59, in __call__
    sourceAnnotations=getattr(debug_flags, 'sourceAnnotations', 0),
  File "/home/xispa/buildout-cache/eggs/zope.pagetemplate-3.6.3-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 132, in pt_render
    strictinsert=0, sourceAnnotations=sourceAnnotations
  File "/home/xispa/buildout-cache/eggs/five.pt-2.2.4-py2.7.egg/five/pt/engine.py", line 98, in __call__
    return self.template.render(**kwargs)
  File "/home/xispa/buildout-cache/eggs/z3c.pt-3.1.0-py2.7.egg/z3c/pt/pagetemplate.py", line 158, in render
    return base_renderer(**context)
  File "/home/xispa/buildout-cache/eggs/Chameleon-3.2-py2.7.egg/chameleon/zpt/template.py", line 297, in render
    return super(PageTemplate, self).render(**_kw)
  File "/home/xispa/buildout-cache/eggs/Chameleon-3.2-py2.7.egg/chameleon/template.py", line 191, in render
    raise_with_traceback(exc, tb)
  File "/home/xispa/buildout-cache/eggs/Chameleon-3.2-py2.7.egg/chameleon/template.py", line 171, in render
    self._render(stream, econtext, rcontext)
  File "9d67db03324cd1649323746712e6c6a8.py", line 152, in render
AttributeError: 'NoneType' object has no attribute 'getSampler'

 - Expression: "        python:sample.getS"
 - Filename:   ... /bika/lims/browser/templates/stickers/Code_128_1x48mm.pt
 - Location:   (line 26: col 14)
 - Source:     sampler           python:sample.getSampler();
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
 - Arguments:  modules: 
               sample: 
               ar: 
               container: 
               wrapped_repeat: 
               portal_url: http://localhost:8080/senaite
               traverse_subpath: 
               partnr: 001
               template: 
               translate: 
               repeat: {...} (0)
               views: 
               args: 
               here: 
               part: 
               user: 
               nothing: 
               ar_id: 
               default: 
               request: 
               item: 
               loop: {...} (0)
               context: 
               portal_state: 
               view: 
               root: 
               options: {...} (0)
               target_language:

Desired behavior after PR is merged

The PDF with the stickers correctly rendered for the received Analysis Requests is displayed

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

auto_stickers_action = self.portal.bika_setup.getAutoPrintStickers()
if transitioned and action == auto_stickers_action:
self.request.form['uids'] = transitioned
self.workflow_action_print_stickers()
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for removing that backslash madness, which always looks to me like a huge regular expression. Finally, I can understand that little piece of code:)

However, looking at the return value return len(transitioned), dest I see nowhere this dest value set differently than None. So I don't understand that logic what happens then. Should dest be self.destination_url?

We should really get away from using classes as multi-state-machines with implicit usage of instance variables, always gives me headaches...

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest, did not recall on that "dest" variable. Since the redirection is managed by workflow_action_print_stickers, I think it should be totally safe to remove this dest, but I will check if anyone is expecting this tuple return (I'd say that no one).

Copy link
Member Author

Choose a reason for hiding this comment

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

In any case, there is no sense to have this whole logic inside submitTransition, especially because this workflow logic should not live inside bika_listing imo, rather in workflow.<portal_type>.events.* . I will take care of this soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this logic needs to go out from the listing code, agree.
I think so as well that other places handle that None URL gracefully, at least the places I can remember. So I'm fine to let that in, ok?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, then I will just do dest = self.destination_url (its value is already assigned in workflow_action_print_stickers) as a temporary solution until we get rid of this crap.

@ramonski ramonski merged commit 7460e7c into senaite:master Feb 21, 2018
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