Don't stomp "type" built-in and don't import that which is not used
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 19 Mar 2011 03:59:00 +0000 (03:59 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 19 Mar 2011 03:59:00 +0000 (03:59 +0000)
Also provide a little more docstring action.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@19817 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/python/oils/utils/utils.py

index 12b3448..3f83c29 100644 (file)
 # 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,9 +39,19 @@ def is_db_true(data):
         return False
     return True
 
+def login(username, password, login_type=None, workstation=None):
+    """
+    Login to the server and get back an authentication token
+
+    @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
 
-def login(username, password, type=None, workstation=None):
-    ''' Login to the server and get back an authtoken'''
+    @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)
 
@@ -60,7 +68,7 @@ def login(username, password, type=None, workstation=None):
         {   'workstation' : workstation,
             'username' : username,
             'password' : password,
-            'type' : type
+            'type' : login_type
         }
     )