WEEE-Open / pytarallo

Python T.A.R.A.L.L.O. API
MIT License
2 stars 4 forks source link

Replace Tarallo.status() with something more efficient #14

Closed steemnd closed 5 years ago

steemnd commented 5 years ago

As pointed out here https://github.com/WEEE-Open/python-tarallo/issues/6#issuecomment-436801357, the login() method already checks its own request status by returning a boolean.

We should at the end of each request:

  1. Check the status_code for 403
  2. If it's 403, attempt login()
  3. If login() returns True try to resend the request, else QUIT
  4. If the status_code is still 403 after resending the request after successful login, QUIT

The easiest way would be repeating the same piece of code for each method, but sounds trivial, however making a method for this procedure requires additional attention.

lvps commented 5 years ago

What about a custom decorator that retries the function call (just once) on a 403 response, if that's actually possible?