0

Rauth OAuth1Session 试图使用 requests_cache 来利用猴子修补的 Session 来维护响应的持久存储,Rauth OAuth1Session 似乎并不好。

假设密钥已在其他地方设置...

import requests
import requests_cache
requests_cache.install_cache('test-cache', backend='sqlite', expire_after=300)
from rauth.session import OAuth1Session

session = OAuth1Session(consumer_key=CONSUMER_KEY,
    consumer_secret=CONSUMER_SECRET,
    access_token=ACCESS_TOKEN,
    access_token_secret=ACCESS_SECRET)
r = session.get("http://www.paperbackswap.com/api/v2/index.php", params={"RequestType": "MemberData"});

结果是:

>  File "run.py", line 5, in <module>
>    from rauth.session import OAuth1Session
>  File "/Users/jasharmon/src/oauth_1.0a_tool/venv/lib/python2.7/site-packages/rauth/__init__.py", line 22, in <module>
>    from .service import OAuth1Service, OAuth2Service, OflyService
>  File "/Users/jasharmon/src/oauth_1.0a_tool/venv/lib/python2.7/site-packages/rauth/service.py", line 10, in <module>
>    from rauth.session import OAuth1Session, OAuth2Session, OflySession
>  File "/Users/jasharmon/src/oauth_1.0a_tool/venv/lib/python2.7/site-packages/rauth/session.py", line 28, in <module>
>    class RauthSession(Session):
>  File "/Users/jasharmon/src/oauth_1.0a_tool/venv/lib/python2.7/site-packages/rauth/session.py", line 29, in RauthSession
>    __attrs__ = Session.__attrs__ + ['service']
>AttributeError: 'function' object has no attribute '__attrs__'
4

1 回答 1

2

仅供参考,这最终是因为 requests_cache 使用 lambda 来猴子补丁。在此处修复: https ://github.com/reclosedev/requests-cache/issues/28

于 2014-09-29T19:41:44.397 回答