[open-ils-commits] r57 - constrictor/trunk/contrib/evergreen
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Nov 26 17:25:51 EST 2008
Author: erickson
Date: 2008-11-26 17:25:46 -0500 (Wed, 26 Nov 2008)
New Revision: 57
Modified:
constrictor/trunk/contrib/evergreen/eg_checkout.py
constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py
constrictor/trunk/contrib/evergreen/eg_tasks.py
constrictor/trunk/contrib/evergreen/eg_utils.py
constrictor/trunk/contrib/evergreen/eg_workflow.py
Log:
more API drift repairs. now using checkout.full / removed all traces of checkout.permit
Modified: constrictor/trunk/contrib/evergreen/eg_checkout.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_checkout.py 2008-11-26 21:47:39 UTC (rev 56)
+++ constrictor/trunk/contrib/evergreen/eg_checkout.py 2008-11-26 22:25:46 UTC (rev 57)
@@ -19,12 +19,9 @@
patronID = dm.getThreadData(PROP_PATRON_IDS)
copyBarcode = dm.getThreadData(PROP_COPY_BARCODES, True)
- evt = doCheckoutPermit(copyBarcode, patronID)
+ evt = doCheckout(copyBarcode, patronID)
if not evt: return False
- evt = doCheckout(copyBarcode, patronID, evt['payload'])
- if not evt: return False
-
return True
ScriptManager.go(CheckoutScript())
Modified: constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py 2008-11-26 21:47:39 UTC (rev 56)
+++ constrictor/trunk/contrib/evergreen/eg_checkout_roundtrip.py 2008-11-26 22:25:46 UTC (rev 57)
@@ -19,12 +19,9 @@
patronID = dm.getThreadData(PROP_PATRON_IDS)
copyBarcode = dm.getThreadData(PROP_COPY_BARCODES, True)
- evt = doCheckoutPermit(copyBarcode, patronID)
+ evt = doCheckout(copyBarcode, patronID)
if not evt: return False
- evt = doCheckout(copyBarcode, patronID, evt['payload'])
- if not evt: return False
-
evt = doCheckin(copyBarcode)
if not evt: return False
Modified: constrictor/trunk/contrib/evergreen/eg_tasks.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_tasks.py 2008-11-26 21:47:39 UTC (rev 56)
+++ constrictor/trunk/contrib/evergreen/eg_tasks.py 2008-11-26 22:25:46 UTC (rev 57)
@@ -26,27 +26,12 @@
def register(self):
TASKS[self.name] = self.wrap()
-class CheckoutPermitTask(AbstractMethodTask):
- def __init__(self):
- AbstractMethodTask.__init__(self)
- self.service = OILS_APP_CIRC
- self.method = 'open-ils.circ.checkout.permit'
-
- def run(self, **kw):
- ''' kw[copy_barcode] The item barcode
- kw[patron_id] The user's id '''
-
- return self.runMethod(eg_utils.authtoken(), dict(kw))
-
-registerTask(CheckoutPermitTask())
-
-
class CheckoutTask(AbstractMethodTask):
def __init__(self):
AbstractMethodTask.__init__(self)
self.service = OILS_APP_CIRC
- self.method = 'open-ils.circ.checkout'
+ self.method = 'open-ils.circ.checkout.full'
def run(self, **kw):
''' kw[copy_barcode] The item barcode
Modified: constrictor/trunk/contrib/evergreen/eg_utils.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_utils.py 2008-11-26 21:47:39 UTC (rev 56)
+++ constrictor/trunk/contrib/evergreen/eg_utils.py 2008-11-26 22:25:46 UTC (rev 57)
@@ -154,7 +154,7 @@
evt = Event.parse_event(result)
if evt and not evt.success:
- raise AuthException(evt.textcode)
+ raise AuthException(evt.text_code)
__authtoken = result['payload']['authtoken']
return __authtoken
Modified: constrictor/trunk/contrib/evergreen/eg_workflow.py
===================================================================
--- constrictor/trunk/contrib/evergreen/eg_workflow.py 2008-11-26 21:47:39 UTC (rev 56)
+++ constrictor/trunk/contrib/evergreen/eg_workflow.py 2008-11-26 22:25:46 UTC (rev 57)
@@ -2,49 +2,41 @@
from eg_data import DataManager
from eg_utils import ILSEventException
from constrictor.log import *
-from oils.utils.utils import eventText, eventCode
+from oils.event import Event
from oils.const import *
-from osrf.json import osrfObjectToJSON
+import osrf.json
-SUCCESS = {'textcode':'SUCCESS', 'ilsevent':0}
+SUCCESS = {'text_code':'SUCCESS', 'ilsevent':0}
-def doCheckoutPermit(copyBarcode, patronID, recurse=False):
- evt = TASKS['CheckoutPermitTask'].run(copy_barcode=copyBarcode, patron_id=patronID)
- logInfo("CheckoutPermit(%s, %s) -> %s" % (copyBarcode, patronID, eventText(evt)))
+def doCheckout(copyBarcode, patronID, recurse=False):
- if eventText(evt) == OILS_EVENT_SUCCESS:
+ evt = TASKS['CheckoutTask'].run(
+ copy_barcode=copyBarcode, patron_id=patronID)
+ evt_txt = Event.parse_event(evt).text_code
+ logInfo("Checkout(%s,%s) -> %s" % (copyBarcode, patronID, evt_txt))
+
+ if evt_txt == OILS_EVENT_SUCCESS:
return evt
if recurse: return None
- if eventText(evt) == 'OPEN_CIRCULATION_EXISTS':
+ if evt_txt == 'OPEN_CIRCULATION_EXISTS':
evt = doCheckin(copyBarcode)
- if eventText(evt) == OILS_EVENT_SUCCESS:
- return doCheckoutPermit(copyBarcode, patronID, True)
+ if evt_txt == OILS_EVENT_SUCCESS:
+ return doCheckout(copyBarcode, patronID, True)
logInfo("* Unable to checkin open circ: %s" % copyBarcode)
return None
-def doCheckout(copyBarcode, patronID, permitKey):
-
- evt = TASKS['CheckoutTask'].run(
- copy_barcode=copyBarcode, patron_id=patronID, permit_key=permitKey)
- logInfo("Checkout(%s,%s) -> %s" % (copyBarcode, patronID, eventText(evt)))
-
- if eventText(evt) == OILS_EVENT_SUCCESS:
- return evt
-
- return None
-
-
def doRenew(copyBarcode):
evt = TASKS['RenewTask'].run(copy_barcode=copyBarcode)
- logInfo("Checkout(%s) -> %s" % (copyBarcode, eventText(evt)))
+ evt_txt = Event.parse_event(evt).text_code
+ logInfo("Checkout(%s) -> %s" % (copyBarcode, evt_txt))
- if eventText(evt) == OILS_EVENT_SUCCESS:
+ if evt_txt == OILS_EVENT_SUCCESS:
return evt
return None
@@ -54,18 +46,19 @@
def doCheckin(copyBarcode):
evt = TASKS['CheckinTask'].run(copy_barcode=copyBarcode)
- logInfo("Checkin(%s) -> %s" % (copyBarcode, eventText(evt)))
+ evt_txt = Event.parse_event(evt).text_code
+ logInfo("Checkin(%s) -> %s" % (copyBarcode, evt_txt))
- if eventText(evt) == OILS_EVENT_SUCCESS or eventText(evt) == 'NO_CHANGE':
+ if evt_txt == OILS_EVENT_SUCCESS or evt_txt == 'NO_CHANGE':
return SUCCESS
- if eventText(evt) == 'ROUTE_ITEM':
+ if evt_txt == 'ROUTE_ITEM':
logInfo("Cancelling post-checkin transit...")
- evt = TASKS['AbortTransitTask'].run(copy_barcode=copyBarcode)
+ res = TASKS['AbortTransitTask'].run(copy_barcode=copyBarcode)
- if eventCode(evt): # transit returns "1" on success
- logError("Unable to abort transit for %s : %s" % (copyBarcode, osrfObjectToJSON(evt)))
+ if Event.parse_event(res): # transit returns "1" on success
+ logError("Unable to abort transit for %s : %s" % (copyBarcode, osrf.json.to_json(evt)))
return None
return SUCCESS
@@ -79,10 +72,10 @@
evt = TASKS['TitleHoldPermitTask'].run(
title_id=titleID, patron_id=patronID, pickup_lib=pickupLib)
- if eventCode(evt):
+ if Event.parse_event(evt):
raise ILSEventException(
"TitleHoldPermit(%s, %s, %s) failed -> %s" % (
- titleID, patronID, pickupLib, osrfObjectToJSON(evt)))
+ titleID, patronID, pickupLib, osrf.json.to_json(evt)))
if str(evt) != '1':
logInfo("TitleHoldPermit(%s, %s, %s) not allowed -> %s" % (
@@ -103,12 +96,12 @@
if isinstance(evt, list):
evts = []
for e in evt:
- evts.append(e['textcode'])
+ evts.append(e['text_code'])
logInfo("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, str(evts)))
return None
- if eventCode(evt):
- logInfo("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, eventCode(evt)))
+ if Event.parse_event(evt):
+ logInfo("TitleHold(%s, %s, %s) -> %s" % (titleID, patronID, pickupLib, Event.parse_event(evt).code))
return None
if str(evt) != '1':
@@ -122,9 +115,10 @@
def doTitleHoldCancel(holdID):
evt = TASKS['TitleHoldCancelTask'].run(hold_id=holdID)
+ evt_txt = Event.parse_event(evt).text_code
- if eventCode(evt):
- if eventText(evt) == 'ACTION_HOLD_REQUEST_NOT_FOUND':
+ if Event.parse_event(evt):
+ if evt_txt == 'ACTION_HOLD_REQUEST_NOT_FOUND':
return True
raise ILSEventException(
"TitleHoldCancel(%s) failed -> %s" % (holdID, str(evt)))
@@ -134,7 +128,7 @@
def doTitleHoldFetchAll(patronID):
evt = TASKS['TitleHoldFetchAllTask'].run(patron_id=patronID)
- if eventCode(evt):
+ if Event.parse_event(evt):
raise ILSEventException(
"TitleHoldFetchAll(%s) failed -> %s" % (patronID, evt))
return evt
More information about the open-ils-commits
mailing list