From: Art Rhyno Date: Sun, 26 Jun 2011 04:16:52 +0000 (-0400) Subject: Workaround for version changes - need to go back and clean this X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=946450fa533a92b2a4feca81233cd736e1606aad;p=Syrup.git Workaround for version changes - need to go back and clean this up better but this will keep integration in sync for now. Signed-off-by: Art Rhyno --- diff --git a/conifer/integration/evergreen_site.py b/conifer/integration/evergreen_site.py index b9a3eee..284a41e 100644 --- a/conifer/integration/evergreen_site.py +++ b/conifer/integration/evergreen_site.py @@ -168,26 +168,23 @@ class EvergreenIntegration(object): @memoize(timeout=CACHE_TIME) def _item_status(self, bib_id): - # At this point, status information does not require the opensrf - # bindings, I am not sure there is a use case where an evergreen - # site would not have access to these but will leave for now - # since there are no hardcoded references - assert self.RESERVES_DESK_NAME, 'No RESERVES_DESK_NAME specified!' - try: - counts = E1(OPENSRF_COPY_COUNTS, bib_id, 1, 0) - lib = desk = avail = vol = anystatus_here = 0 - dueinfo = '' - callno = '' - circmod = '' - alldues = [] - - # Note: MassLNC requires this, need to add a version - # value to settings and consider required opensrf to - # to be installed for any evergreen site. - # - # for org, skip1, callnum, skip2, loc, stats in counts: + def sort_out_status(counts, version, sort_lib, sort_desk, sort_avail, + sort_callno, sort_dueinfo, sort_circmod, sort_alldues): + + lib = sort_lib + desk = sort_desk + avail = sort_avail + callno = sort_callno + dueinfo = sort_dueinfo + circmod = sort_circmod + alldues = sort_alldues + try: + # Note: MassLNC requires this, need to add a version + # value to settings and consider required opensrf to + # to be installed for any evergreen site. + # + # for org, skip1, callnum, skip2, loc, stats in counts: - for org, callnum, loc, stats in counts: callprefix = '' callsuffix = '' if len(callno) == 0: @@ -222,9 +219,10 @@ class EvergreenIntegration(object): callno = callnum # Another MassLNC variation, needs same refactoring as above - # copyids = E1(OPENSRF_CN_CALL, bib_id, [callnum], org) - - copyids = E1(OPENSRF_CN_CALL, bib_id, callnum, org) + if version >= 2.1: + copyids = E1(OPENSRF_CN_CALL, bib_id, [callnum], org) + else: + copyids = E1(OPENSRF_CN_CALL, bib_id, callnum, org) # we want to return the resource that will be returned first if # already checked out @@ -302,12 +300,44 @@ class EvergreenIntegration(object): callno = callno + callsuffix if voltest: vol = int(voltest.group(1)) + + + except: + print "due date/call problem: ", bib_id + print "*** print_exc:" + traceback.print_exc() + return (lib, desk, avail, callno, dueinfo, circmod, alldues) - except: - print "due date/call problem: ", bib_id - print "*** print_exc:" - traceback.print_exc() - return None # fail silently in production if there's an opensrf or time related error. + + # At this point, status information does not require the opensrf + # bindings, I am not sure there is a use case where an evergreen + # site would not have access to these but will leave for now + # since there are no hardcoded references + assert self.RESERVES_DESK_NAME, 'No RESERVES_DESK_NAME specified!' + + lib = desk = avail = vol = anystatus_here = 0 + dueinfo = '' + callno = '' + circmod = '' + alldues = [] + + counts = E1(OPENSRF_COPY_COUNTS, bib_id, 1, 0) + + version = getattr(settings, 'EVERGREEN_VERSION', + 2.0) + + #TODO: clean this up, a hackish workaround for now + if version >= 2.1: + for org, skip1, callnum, skip2, loc, stats in counts: + lib, desk, avail, callno, dueinfo, circmod, alldues = sort_out_status(counts, + version, lib, desk, avail, callno, dueinfo, circmod, alldues) + else: + for org, callnum, loc, stats in counts: + lib, desk, avail, callno, dueinfo, circmod, alldues = sort_out_status(counts, + version, lib, desk, avail, callno, dueinfo, circmod, alldues) + + return (lib, desk, avail, callno, dueinfo, circmod, alldues) + # You'll need to define OSRF_CAT_SEARCH_ORG_UNIT, either by overriding its diff --git a/conifer/local_settings.py.example b/conifer/local_settings.py.example index 1f8d092..ca763ce 100644 --- a/conifer/local_settings.py.example +++ b/conifer/local_settings.py.example @@ -51,6 +51,7 @@ CAS_AUTHENTICATION = False CAS_SERVER_URL = 'https://uwinid.uwindsor.ca/cas/' EVERGREEN_SERVER = 'www.concat.ca' +EVERGREEN_VERSION = 2.1 RESERVES_DESK_NAME = 'Leddy: Course Reserves - Main Bldng - 1st Flr - Reserve Counter at Circulation Desk' SYRUP_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S' SYRUP_DUE_FORMAT = '%b %d %Y, %r'