git://git.onelab.eu
/
myslice.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
notes on using the new API, and a first untested stab at that in manifoldAPI
[myslice.git]
/
auth
/
manifoldbackend.py
diff --git
a/auth/manifoldbackend.py
b/auth/manifoldbackend.py
index
dbaf863
..
73ba446
100644
(file)
--- a/
auth/manifoldbackend.py
+++ b/
auth/manifoldbackend.py
@@
-2,7
+2,7
@@
import time
from django.contrib.auth.models import User
from django.contrib.auth.models import User
-from
engine.manifoldapi import ManifoldAPI
+from
manifold.manifoldapi import ManifoldAPI, ManifoldResult
# Name my backend 'ManifoldBackend'
class ManifoldBackend:
# Name my backend 'ManifoldBackend'
class ManifoldBackend:
@@
-21,10
+21,14
@@
class ManifoldBackend:
auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
api = ManifoldAPI(auth)
# Authenticate user and get session key
auth = {'AuthMethod': 'password', 'Username': username, 'AuthString': password}
api = ManifoldAPI(auth)
# Authenticate user and get session key
- session = api.GetSession()
- if not session :
- return None
+ # the new API would expect Get('local:session') instead
+ session_result = api.GetSession()
+ session = session_result.ok_value()
+ if not session:
+ print "GetSession failed",session_result.error()
+ return
+ print 'DEALING with session',session
#self.session = session
# Change GetSession() at some point to return expires as well
expires = time.time() + (24 * 60 * 60)
#self.session = session
# Change GetSession() at some point to return expires as well
expires = time.time() + (24 * 60 * 60)
@@
-34,8
+38,13
@@
class ManifoldBackend:
self.api = api
# Get account details
self.api = api
# Get account details
- person = api.GetPersons(auth)[0]
- self.person = person
+ # the new API would expect Get('local:user') instead
+ persons_result = api.GetPersons(auth)
+ persons = persons_result.ok_value()
+ if not persons:
+ print "GetPersons failed",persons_result.error()
+ return
+ person = persons[0]
request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': expires}
except:
request.session['manifold'] = {'auth': api.auth, 'person': person, 'expires': expires}
except: