diff options
author | Leif Johansson <leifj@sunet.se> | 2011-05-10 09:44:56 +0200 |
---|---|---|
committer | Leif Johansson <leifj@sunet.se> | 2011-05-10 09:44:56 +0200 |
commit | 4e14a262829b763a6bcbd7e8fc376b51c1094509 (patch) | |
tree | 5cbafe2fd4aa6f6a96debe88e20eb987d5e5e54c /src/meetingtools/ac | |
parent | 4dccf3f3a8b06d47122e8e9ac995af0eee9bcec7 (diff) |
export session as random password to acp
Diffstat (limited to 'src/meetingtools/ac')
-rw-r--r-- | src/meetingtools/ac/api.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/meetingtools/ac/api.py b/src/meetingtools/ac/api.py index 59aa2d8..c26cd29 100644 --- a/src/meetingtools/ac/api.py +++ b/src/meetingtools/ac/api.py @@ -14,6 +14,7 @@ from lxml import etree import pprint from meetingtools.site_logging import logger import lxml +from django.http import HttpResponseRedirect class ACPException(Exception): def __init__(self, value): @@ -63,12 +64,13 @@ def _getset(dict,key,value=None): class ACPClient(): - def __init__(self,url,username=None,password=None): + def __init__(self,url,username=None,password=None,cache=True): self.url = url self.session = None if username and password: self.login(username,password) - self._cache = {'login':{},'group':{}} + if cache: + self._cache = {'login':{},'group':{}} def request(self,method,p={},raise_error=False): if self.session: @@ -99,10 +101,17 @@ class ACPClient(): return r; + def redirect_to(self,url): + if self.session: + return HttpResponseRedirect("%s?BREEZESESSION=%s" % (url,self.session)) + else: + return HttpResponseRedirect(url) + def login(self,username,password): result = self.request('login',{'login':username,'password':password}) if result.is_error(): raise result.exception() + return result def find_or_create_principal(self,key,value,type,dict): if not self._cache.has_key(type): |