X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/6952a4c7812d1cbd2da8aa60ba3ff1ae183248e5..3b0d1718ec6c9dddcee4a4620384a83e30ff6f2f:/apps/apiclient/__init__.py?ds=sidebyside diff --git a/apps/apiclient/__init__.py b/apps/apiclient/__init__.py index 38ce26e4..56ecb96d 100644 --- a/apps/apiclient/__init__.py +++ b/apps/apiclient/__init__.py @@ -3,7 +3,7 @@ import urllib import json import oauth2 -from apiclient.settings import WL_CONSUMER_KEY, WL_CONSUMER_SECRET, WL_API_URL +from apiclient.settings import WL_CONSUMER_KEY, WL_CONSUMER_SECRET, WL_API_URL, BETA_API_URL if WL_CONSUMER_KEY and WL_CONSUMER_SECRET: @@ -20,9 +20,10 @@ class NotAuthorizedError(BaseException): pass -def api_call(user, path, data=None): +def api_call(user, path, data=None, beta=False): from .models import OAuthConnection - conn = OAuthConnection.get(user) + api_url = BETA_API_URL if beta else WL_API_URL + conn = OAuthConnection.get(user=user, beta=beta) if not conn.access: raise NotAuthorizedError("No WL authorization for user %s." % user) token = oauth2.Token(conn.token, conn.token_secret) @@ -31,12 +32,12 @@ def api_call(user, path, data=None): data = json.dumps(data) data = urllib.urlencode({"data": data}) resp, content = client.request( - "%s%s" % (WL_API_URL, path), + "%s%s" % (api_url, path), method="POST", body=data) else: resp, content = client.request( - "%s%s" % (WL_API_URL, path)) + "%s%s" % (api_url, path)) status = resp['status'] if status == '200':