docassemble icon indicating copy to clipboard operation
docassemble copied to clipboard

Problem with example in the docs

Open gustavengstrom opened this issue 3 years ago • 2 comments

In the example: "E-mailing or texting the user a link for purposes of using the touchscreen" https://docassemble.org/docs/recipes.html#hybrid

There is a version has multi_user=False where the first interview references: second-interview.yml.

When trying this example the user always ends up at the: timeout_screen and never at the final_screen

When trying to find the error I discovered that removing the line: r.delete(redis_key) fixes this issue.

However the key thus remains in the DB which clearly is not optimal...

gustavengstrom avatar Mar 24 '22 06:03 gustavengstrom

Thanks. I didn't realize the logic in the mandatory block was non-idempotent. I rewrote it so it doesn't have that problem any more.

jhpyle avatar Mar 24 '22 22:03 jhpyle

Thanks have to read up on non-idempotency in the docs! Question: it appears to me that the code can be further simplified. The variable signature_obtained is redundant and can be removed and the same goes for two of the del result statements.

I thus changed the first code block to :

---
mandatory: True
code: |
  email_sent
  signature
  final_screen
---

and the last to:

---
code: |
  result = r.get_data(redis_key)
  if result is None:
    timeout_screen
  elif result == 'waiting':
    waiting_screen
  signature = DAFile('signature')
  signature.initialize(filename="signature.png")
  signature.write(result, binary=True)
  signature.commit()
  r.delete(redis_key)
  del result

Let me know if I am missing something?

gustavengstrom avatar Mar 25 '22 08:03 gustavengstrom

I'm going through old GitHub issues and I saw I didn't respond to this. I think the difference is probably just a matter of style. If it works correctly the way you have it, that should be fine.

jhpyle avatar Aug 13 '22 14:08 jhpyle