Forum Archive

workflow variables not updating in will_close() handler

roosterboy197

I have a custom UI I'm presenting in a Python script action. My custom view class has a will_close() handler where I want to save off some values to two workflow variables I've set up in previous steps. Here's my handler:

def will_close(self):
    clist = u'\n'.join(u'{} :: {}'.format(_, self.wordlist[_]) for _ in self.correct_words)
    wlist = u'\n'.join(u'{} :: {}'.format(_, self.wordlist[_]) for _ in self.wrong_words)
    workflow.set_variable('correct_words', clist)
    workflow.set_variable('wrong_words', wlist)

The values of correct_words and wrong_words are output using Set File Contents actions to two files in Dropbox, creating them if they don't already exist. The files are being created as they should, but they are empty!

If I add some print statements to my will_close() handler, I can see in the console that clist and wlist contain exactly what they should contain.

If I pause the workflow at the first Set File Contents action, I can see that the variable correct_words contains no value.

Any suggestions?

roosterboy197

OK, well, I was able to save off my data using editor.set_file_contents() to do it directly instead of setting the filename with workflow.set_variable() and then using a Set File Contents action but I'm still curious why the latter doesn't work.