[open-ils-commits] r7792 - trunk/Open-ILS/src/python/oils/utils
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Sep 16 13:51:34 EDT 2007
Author: erickson
Date: 2007-09-16 13:43:09 -0400 (Sun, 16 Sep 2007)
New Revision: 7792
Modified:
trunk/Open-ILS/src/python/oils/utils/utils.py
Log:
added a login method
Modified: trunk/Open-ILS/src/python/oils/utils/utils.py
===================================================================
--- trunk/Open-ILS/src/python/oils/utils/utils.py 2007-09-15 01:51:00 UTC (rev 7791)
+++ trunk/Open-ILS/src/python/oils/utils/utils.py 2007-09-16 17:43:09 UTC (rev 7792)
@@ -14,20 +14,15 @@
# -----------------------------------------------------------------------
import re, md5
+from osrf.ses import osrfAtomicRequest
+from osrf.log import *
+
# -----------------------------------------------------------------------
# Grab-bag of general utility functions
# -----------------------------------------------------------------------
-
-# -----------------------------------------------------------------------
-# more succinct search/replace call
-# -----------------------------------------------------------------------
-def replace(str, pattern, replace):
- return re.compile(pattern).sub(replace, str)
-
-
def isEvent(evt):
return (evt and isinstance(evt, dict) and evt.get('ilsevent') != None)
@@ -54,3 +49,26 @@
o[x] = 1
return o.keys()
+
+def login(username, password, type=None, workstation=None):
+ ''' Login to the server and get back an authtoken'''
+
+ osrfLogInfo("attempting login with user " + username)
+
+ seed = osrfAtomicRequest(
+ 'open-ils.auth',
+ 'open-ils.auth.authenticate.init', username)
+
+ # generate the hashed password
+ password = md5sum(seed + md5sum(password))
+
+ return osrfAtomicRequest(
+ 'open-ils.auth',
+ 'open-ils.auth.authenticate.complete',
+ { 'workstation' : workstation,
+ 'username' : username,
+ 'password' : password,
+ 'type' : type
+ }
+ )
+
More information about the open-ils-commits
mailing list