[open-ils-commits] r19817 - trunk/Open-ILS/src/python/oils/utils (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Mar 18 23:59:03 EDT 2011
Author: dbs
Date: 2011-03-18 23:59:00 -0400 (Fri, 18 Mar 2011)
New Revision: 19817
Modified:
trunk/Open-ILS/src/python/oils/utils/utils.py
Log:
Don't stomp "type" built-in and don't import that which is not used
Also provide a little more docstring action.
Modified: trunk/Open-ILS/src/python/oils/utils/utils.py
===================================================================
--- trunk/Open-ILS/src/python/oils/utils/utils.py 2011-03-19 03:06:58 UTC (rev 19816)
+++ trunk/Open-ILS/src/python/oils/utils/utils.py 2011-03-19 03:59:00 UTC (rev 19817)
@@ -13,20 +13,18 @@
# GNU General Public License for more details.
# -----------------------------------------------------------------------
-import re, hashlib
+import hashlib
import osrf.ses
-from osrf.log import *
-
-
# -----------------------------------------------------------------------
# Grab-bag of general utility functions
# -----------------------------------------------------------------------
-def md5sum(str):
- m = hashlib.md5()
- m.update(str)
- return m.hexdigest()
+def md5sum(string):
+ """Return an MD5 message digest for a given input string"""
+ md5 = hashlib.md5()
+ md5.update(string)
+ return md5.hexdigest()
def unique(arr):
''' Unique-ify a list. only works if list items are hashable '''
@@ -41,10 +39,20 @@
return False
return True
+def login(username, password, login_type=None, workstation=None):
+ """
+ Login to the server and get back an authentication token
-def login(username, password, type=None, workstation=None):
- ''' Login to the server and get back an authtoken'''
+ @param username: user name
+ @param password: password
+ @param login_type: one of 'opac', 'temp', or 'staff' (default: 'staff')
+ @param workstation: name of the workstation to associate with this login
+ @rtype: string
+ @return: a string containing an authentication token to pass as
+ a required parameter of many OpenSRF service calls
+ """
+
log_info("attempting login with user " + username)
seed = osrf.ses.ClientSession.atomic_request(
@@ -60,7 +68,7 @@
{ 'workstation' : workstation,
'username' : username,
'password' : password,
- 'type' : type
+ 'type' : login_type
}
)
More information about the open-ils-commits
mailing list