no access to context['document']

Technical aspects, customization, code samples.
Post Reply
merlin81
Posts: 5
Joined: Thu Jan 14, 2021 5:46 pm

no access to context['document']

Post by merlin81 »

I've setup mayan as described in manual at a proxmox lxc container with Debian buster for testing. On several machines all is well and my changes are working. On one machine I get error AttributeError; 'NoneType' object has no attribute 'open' when I try to access document. But not always, a few times document is not None and workflow is ok. The document I need is from context document=context['document'] in workflow execute method. I also tried to get simple checksum, but document most time is None (error changes to attribute checksum for sure).
I've tried to debug my method, only thing I can say document remains None. Can someone give me a hint what to do ? I think it could have something to do with threading, so the document context is not available when I access it.

thanks in advance !
merlin81
Posts: 5
Joined: Thu Jan 14, 2021 5:46 pm

Re: no access to context['document']

Post by merlin81 »

after some debugging I've found I need to wait for ocr to finish. For now I do this with a state. Would be nice to know how to wait inside my codeblock.
User avatar
rosarior
Developer
Developer
Posts: 624
Joined: Tue Aug 21, 2018 3:28 am
Location: Puerto Rico
Contact:

Re: no access to context['document']

Post by rosarior »

This is the reason we added events. You can subscribe to the event

Code: Select all

event_ocr_document_version_finish
which is committed when the processing ends. From the instance passed to you by this event you can also infer the document with

Code: Select all

instance.document
.
Post Reply