summaryrefslogtreecommitdiff
path: root/src/meetingtools/ac
diff options
context:
space:
mode:
authorLeif Johansson <leifj@sunet.se>2012-01-17 10:51:46 +0100
committerLeif Johansson <leifj@sunet.se>2012-01-17 10:51:46 +0100
commit156b905ef6c63647f9ce163a3b0f2c5b9e00ea41 (patch)
tree8ed0fb2a6be0aaf2500d46dea5bd6e3547337d48 /src/meetingtools/ac
parent4b5f7d87df4b59ea8d215ae4a64e68ff73e1dd16 (diff)
move acc_for_user to cluster model as a generic method
Diffstat (limited to 'src/meetingtools/ac')
-rw-r--r--src/meetingtools/ac/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/meetingtools/ac/__init__.py b/src/meetingtools/ac/__init__.py
index b138237..9e47430 100644
--- a/src/meetingtools/ac/__init__.py
+++ b/src/meetingtools/ac/__init__.py
@@ -1,21 +1,25 @@
from meetingtools.ac.api import ACPClient
import time
+from meetingtools.apps.cluster.models import acc_for_user
-def ac_api_client_cache(request,acc):
+def ac_api_client_cache(request,acc=None):
+ if acc == None:
+ acc = acc_for_user(request.user)
tag = 'ac_api_client_%s' % acc.name
if not request.session.has_key(tag):
request.session[tag] = ACPClientWrapper(acc)
return request.session[tag]
-def ac_api_client_nocache(request,acc):
+def ac_api_client_nocache(request,acc=None):
+ if acc == None:
+ acc = acc_for_user(request.user)
return ACPClientWrapper(acc)
ac_api_client = ac_api_client_cache
-def ac_api(request,acc):
+def ac_api(request,acc=None):
return ACPClient(acc.api_url,acc.user,acc.password)
-
MAXCALLS = 10
MAXIDLE = 10