WEEE-Open / pytarallo

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

Suggestion for retrying login #28

Closed lvps closed 5 years ago

lvps commented 5 years ago

Basically, add wrappers for get, post, etc... to Tarallo class:

def get(things, stuff):
    result = self.session.get(things, stuff)
    if result == 403:
        self.retry_login()
        result = self.session.get(things, stuff)
    return result

And call self.get(...) instead of self.session.get(...).

Not sure if it's better, it's just an idea.

This allows retrying login exactly once without recursion.

steemnd commented 5 years ago

As soon as we manage to maintain a <= 1 recursion depth it's fine. The problem is: it's more elegant to:

  1. add 1241251 methods to the Tarallo that rewrap stuff from requests.Session
  2. count the recursion levels
  3. sth else (e.g. stop using the same response code for everything)
steemnd commented 5 years ago

The wrapping methods are actually a nice idea.... We could even stop to write stuff like

self.last_request = self.session.get ....

cause in the end the last_request is handled by this hypothetic get method itself, and we could write instead

self.get...

so tiny... so easy... so smooth.... let's do it dude!

lvps commented 5 years ago

@Hyd3L Yeah dude!