import oils.utils.utils
import osrf.gateway
import osrf.json
+import sys
import tempfile
import urllib2
__authtoken = None
- print("attempting login with user " + username)
-
seed = request(
'open-ils.auth',
'open-ils.auth.authenticate.init', username).send()
result = request(
'open-ils.auth',
- 'open-ils.auth.authenticate.complete',
- { 'workstation' : workstation,
+ 'open-ils.auth.authenticate.complete', {
+ 'workstation' : workstation,
'username' : username,
'password' : password,
'type' : 'staff'
# Pull all of our object definitions together
load_idl()
- # Log in and get an authtoken
- authtoken = login('foo', 'bar')
-
- # Issue a plain old position-dependent request
+ print("Issue a plain old position-dependent request:")
req = request('open-ils.search', 'open-ils.search.biblio.record.copy_count', 105, 891001, None)
res = req.send()
- print(res[0])
+ print("\t%s\n" % res[0])
- # Get a plain Jane acp (copy) object by barcode
+ print("Get a plain Jane acp (copy) object by barcode:")
barcode = '791068-1001'
req = request('open-ils.search', 'open-ils.search.asset.copy.find_by_barcode', barcode)
barcode_copy = req.send()
- print "Raw JSON: ", osrf.json.to_json(barcode_copy)
+ print("\tRaw JSON: %s" % osrf.json.to_json(barcode_copy))
# id() and call_number() are fields defined in fm_IDL.xml
- print "Copy ID: ", barcode_copy.id()
- print "Call number ID: ", barcode_copy.call_number()
+ print("\tCopy ID: %s" % barcode_copy.id())
+ print("\tCall number ID: %s\n" % barcode_copy.call_number())
- # Get a fleshed out copy (now with more fields!) by barcode
+ print("Get a fleshed out copy (now with more fields!) by barcode:")
req = request('open-ils.search', 'open-ils.search.asset.copy.fleshed2.find_by_barcode', barcode)
barcode_copy = req.send()
- print "Raw JSON: ", osrf.json.to_json(barcode_copy)
+ print("\tRaw JSON: %s" % osrf.json.to_json(barcode_copy))
# id() and call_number() are fields defined in fm_IDL.xml
- print "Copy ID: ", barcode_copy.id()
- print "Call number ID: ", barcode_copy.call_number()
-
- # Note - fleshed fields don't appear to be retrievable with the expected syntax
- # The following does _not_ work:
- #
- # print "Copy location: ", barcode_copy.acpl().name()
- #
- # And the following just prints null values for an acpl object:
- #
- # print osrf.json.to_json(barcode_copy.acpl())
-
- # Get a plain acn (callnumber) object by ID
+ print("\tCopy ID: %s" % barcode_copy.id())
+ print("\tCall number ID: %s" % barcode_copy.call_number())
+
+ # Get one of the fleshed fields
+ print("\tCopy location: %s\n" % barcode_copy.location().name())
+
+ print("Get a plain acn (callnumber) object by ID:")
req = request('open-ils.search', 'open-ils.search.asset.call_number.retrieve', barcode_copy.call_number())
call_num = req.send()
- print "Raw JSON: ", osrf.json.to_json(call_num)
- print "Call number ID: ", call_num.id()
- print "Call number label: ", call_num.label()
+ print("\tRaw JSON: %s" % osrf.json.to_json(call_num))
+ print("\tCall number ID: %s" % call_num.id())
+ print("\tCall number label: %s\n" % call_num.label())
+
+ authtoken = ''
+
+ try:
+ # Log in and get an authtoken
+ authtoken = login('foo', 'bar')
+ except AuthException, exc:
+ print("Failed logging in: %s" % str(exc))
+ sys.exit(1)
- # Change the call number and update it
+ print("Change the call number and update it:")
call_num.label('FOOTWICH')
call_num.ischanged(True)