1 # -----------------------------------------------------------------------
2 # Copyright (C) 2007 Georgia Public Library Service
3 # Bill Erickson <billserickson@gmail.com>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 # -----------------------------------------------------------------------
18 from osrf.log import *
22 # -----------------------------------------------------------------------
23 # Grab-bag of general utility functions
24 # -----------------------------------------------------------------------
27 return (evt and isinstance(evt, dict) and evt.get('ilsevent') != None)
31 return evt['ilsevent']
36 return evt['textcode']
46 ''' Unique-ify a list. only works if list items are hashable '''
53 ''' Returns true if the data provided matches what the database considers a true value '''
54 if not data or data == 'f' or str(data) == '0':
59 def login(username, password, type=None, workstation=None):
60 ''' Login to the server and get back an authtoken'''
62 log_info("attempting login with user " + username)
64 seed = osrf.ses.ClientSession.atomic_request(
66 'open-ils.auth.authenticate.init', username)
68 # generate the hashed password
69 password = md5sum(seed + md5sum(password))
71 return osrf.ses.ClientSession.atomic_request(
73 'open-ils.auth.authenticate.complete',
74 { 'workstation' : workstation,
75 'username' : username,
76 'password' : password,