fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add publication options: delay, beta
[redakcja.git]
/
apps
/
apiclient
/
__init__.py
diff --git
a/apps/apiclient/__init__.py
b/apps/apiclient/__init__.py
index
38ce26e
..
2709ca0
100644
(file)
--- a/
apps/apiclient/__init__.py
+++ b/
apps/apiclient/__init__.py
@@
-3,7
+3,7
@@
import urllib
import json
import oauth2
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:
if WL_CONSUMER_KEY and WL_CONSUMER_SECRET:
@@
-20,8
+20,9
@@
class NotAuthorizedError(BaseException):
pass
pass
-def api_call(user, path, data=None):
+def api_call(user, path, data=None
, beta=False
):
from .models import OAuthConnection
from .models import OAuthConnection
+ api_url = BETA_API_URL if beta else WL_API_URL
conn = OAuthConnection.get(user)
if not conn.access:
raise NotAuthorizedError("No WL authorization for user %s." % user)
conn = OAuthConnection.get(user)
if not conn.access:
raise NotAuthorizedError("No WL authorization for user %s." % user)
@@
-31,12
+32,12
@@
def api_call(user, path, data=None):
data = json.dumps(data)
data = urllib.urlencode({"data": data})
resp, content = client.request(
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(
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':
status = resp['status']
if status == '200':