smartfile / client-python

SmartFile API Client (Python).
http://app.smartfile.com/api/
MIT License
20 stars 7 forks source link

Remove name mangling which prevents subclassing OAuthClient. #3

Closed mattdeboard closed 11 years ago

mattdeboard commented 11 years ago

I tried to subclass OAuthClient for a project* but found that the name-mangled instance attributes __access and __client made just rewriting from scratch easier. I've only been working with your guys' library for a day so I apologize if there's a specific reason for the dunder prefix, but inheritance is close to broken in this case.

* _I wanted to get just the response object from _do_request so I could process HTTP requests based on their response code & body instead of catching exceptions thrown by OAuthClient_

btimby commented 11 years ago

Matt, I see no reason not to merge this, thanks for the information. Please let us know if you run into any other problems with the API client.

mattdeboard commented 11 years ago

Thanks Ben. There is another issue in that get_request_token also uses the dunder prefix for self.__request, so a subclass that wants to override that will also run into broken inheritance issues.

I was going to put a fix in for that in this request too but then I saw there's a Client._request method and didn't want to gunk up a straightforward merge.

btimby commented 11 years ago

I think I am going to refactor this a bit anyway. I am not completely happy with calling is_valid() on the token instances. I will probably change it to something like validate(), so it can raise a more specific error message. Right now any problem with the token results in "Missing token" error which is unhelpful.

I will remove the __request (for the request token) at the same time.