[open-ils-commits] r1228 - in servres/trunk/conifer: integration libsystems/evergreen syrup/views (artunit)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Feb 13 22:37:03 EST 2011
Author: artunit
Date: 2011-02-13 22:37:00 -0500 (Sun, 13 Feb 2011)
New Revision: 1228
Added:
servres/trunk/conifer/libsystems/evergreen/opensrf.py
Modified:
servres/trunk/conifer/integration/uwindsor.py
servres/trunk/conifer/libsystems/evergreen/item_status.py
servres/trunk/conifer/syrup/views/items.py
Log:
ils updates for items, more testing to do but basic layer works
Modified: servres/trunk/conifer/integration/uwindsor.py
===================================================================
--- servres/trunk/conifer/integration/uwindsor.py 2011-02-10 17:41:07 UTC (rev 1227)
+++ servres/trunk/conifer/integration/uwindsor.py 2011-02-14 03:37:00 UTC (rev 1228)
@@ -11,7 +11,6 @@
from xml.etree import ElementTree as ET
import csv
import datetime
-import hashlib
import time
import os
import re
@@ -66,8 +65,6 @@
AVAILABLE = [id for id, name in STATUS_DECODE if name == 'Available'][0]
RESHELVING = [id for id, name in STATUS_DECODE if name == 'Reshelving'][0]
-RESERVES_DESK_NAME = 'Leddy: Course Reserves - Main Bldng - 1st Flr - Reserve Counter at Circulation Desk'
-
def item_status(item):
"""
Given an Item object, return three numbers: (library, desk,
@@ -89,12 +86,13 @@
CACHE_TIME = 300
- at memoize(timeout=CACHE_TIME)
+# @memoize(timeout=CACHE_TIME)
def _item_status(bib_id):
if bib_id:
try:
counts = E1(settings.OPENSRF_COPY_COUNTS, bib_id, 1, 0)
+
lib = desk = avail = vol = 0
dueinfo = ''
callno = ''
@@ -120,12 +118,12 @@
"""
attachtest = re.search(settings.ATTACHMENT, callnum)
- if loc == RESERVES_DESK_NAME:
+ if loc == settings.RESERVES_DESK_NAME:
desk += anystatus_here
avail += avail_here
dueinfo = ''
- if (voltest and vol > 0):
+ if (voltest and vol > 0 ):
if (int(voltest.group(1)) > vol):
callsuffix = "/" + callnum
else:
@@ -139,9 +137,9 @@
callno = callnum
lib += anystatus_here
+ print "PRE"
copyids = E1(settings.OPENSRF_CN_CALL, bib_id, callnum, org)
-
"""
we want to return the resource that will be returned first if
already checked out
@@ -153,7 +151,7 @@
if thisloc:
thisloc = thisloc.get("name")
- if thisloc == RESERVES_DESK_NAME:
+ if thisloc == settings.RESERVES_DESK_NAME:
bringfw = attachtest
# multiple volumes
@@ -164,7 +162,7 @@
circmod = circinfo.get("circ_modifier")
circs = circinfo.get("circulations")
- if circs and len(circs) > 0:
+ if circs and len(circs) > 0 and circs.isdigit():
circ = circs[0]
rawdate = circ.get("due_date")
#remove offset info, %z is flakey for some reason
@@ -209,7 +207,7 @@
alldisplay = callnum + ' (Available)'
- if circs and len(circs) > 0:
+ if circs and len(circs) > 0 and circs.isdigit():
alldisplay = '%s (DUE: %s)' % (callnum, time.strftime(settings.DUE_FORMAT,duetime))
alldues.append(alldisplay)
@@ -229,26 +227,6 @@
pass # fail silently in production if there's an opensrf or time related error.
return None
-#for example: auth_token("username at uwindsor.ca", "password", "OWA", "workstation")
-def auth_token(username, password, org, workstation):
- try:
- authtoken = None
- payload = E1('open-ils.auth.authenticate.init', username)
- pw = hashlib.md5(password).hexdigest()
- pw = hashlib.md5(payload + pw).hexdigest()
- authinfo = E1('open-ils.auth.authenticate.complete',{"password":pw, "type":"staff",
- "org": org, "username":username,
- "workstation":workstation})
- if authinfo:
- payload = authinfo.get("payload")
- authtoken = payload.get("authtoken")
- except:
- print "authentication problem: ", username
- print "*** print_exc:"
- traceback.print_exc()
- pass # fail silently in production
- return authtoken
-
def cat_search(query, start=1, limit=10):
bibid=0
bc = re.search('\d{14}', query.strip())
@@ -319,8 +297,8 @@
Given a bib ID, return either a URL for examining the bib record, or None.
"""
if bib_id:
- return ('http://windsor.concat.ca/opac/en-CA'
- '/skin/uwin/xml/rdetail.xml?r=%s&l=1&d=0' % bib_id)
+ return ('%sopac/en-CA'
+ '/skin/uwin/xml/rdetail.xml?r=%s&l=1&d=0' % (EG_BASE, bib_id))
if False: # if USE_Z3950:
# only if we are using Z39.50 for catalogue search. Results including
Modified: servres/trunk/conifer/libsystems/evergreen/item_status.py
===================================================================
--- servres/trunk/conifer/libsystems/evergreen/item_status.py 2011-02-10 17:41:07 UTC (rev 1227)
+++ servres/trunk/conifer/libsystems/evergreen/item_status.py 2011-02-14 03:37:00 UTC (rev 1228)
@@ -1,5 +1,6 @@
import support
from support import ER, E1
+from django.conf import settings
import re
import urllib2
@@ -32,7 +33,8 @@
return xml
if __name__ == '__main__':
- support.initialize('http://windsor.concat.ca/')
+ EG_BASE = 'http://%s/' % settings.EVERGREEN_GATEWAY_SERVER
+ support.initialize(EG_BASE)
print url_to_marcxml('http://windsor.concat.ca/opac/en-CA/skin/uwin/xml/rdetail.xml?r=1971331&t=evergreen&tp=keyword&l=106&d=1&hc=210&rt=keyword')
# from xml.etree import ElementTree as ET
# for t in ET.fromstring(bib_id_to_marcxml('2081089')).getiterator():
Added: servres/trunk/conifer/libsystems/evergreen/opensrf.py
===================================================================
--- servres/trunk/conifer/libsystems/evergreen/opensrf.py (rev 0)
+++ servres/trunk/conifer/libsystems/evergreen/opensrf.py 2011-02-14 03:37:00 UTC (rev 1228)
@@ -0,0 +1,41 @@
+# session-based opensrf calls go here
+
+from conifer.libsystems import marcxml as M
+from conifer.libsystems.evergreen import item_status as I
+from conifer.libsystems.evergreen.support import initialize, E1
+from datetime import date
+from django.conf import settings
+import hashlib
+import os
+import re
+import traceback
+
+def auth_token(username, password, org, workstation):
+ try:
+ authtoken = None
+ payload = E1(settings.OPENSRF_AUTHENTICATE_INIT, username)
+ pw = hashlib.md5(password).hexdigest()
+ pw = hashlib.md5(payload + pw).hexdigest()
+ authinfo = E1(settings.OPENSRF_AUTHENTICATE,{"password":pw, "type":"staff",
+ "org": org, "username":username,
+ "workstation":workstation})
+ if authinfo:
+ payload = authinfo.get("payload")
+ authtoken = payload.get("authtoken")
+ except:
+ print "authentication problem: ", username
+ print "*** print_exc:"
+ traceback.print_exc()
+ pass # fail silently in production
+ return authtoken
+
+def session_cleanup(authtoken):
+ try:
+ payload = E1(settings.OPENSRF_CLEANUP, authtoken)
+ except:
+ print "session problem: ", authtoken
+ print "*** print_exc:"
+ traceback.print_exc()
+ pass # fail silently in production
+
+ return True
Modified: servres/trunk/conifer/syrup/views/items.py
===================================================================
--- servres/trunk/conifer/syrup/views/items.py 2011-02-10 17:41:07 UTC (rev 1227)
+++ servres/trunk/conifer/syrup/views/items.py 2011-02-14 03:37:00 UTC (rev 1228)
@@ -3,9 +3,42 @@
from _common import *
from conifer.plumbing.hooksystem import *
from conifer.syrup import integration
+from django.conf import settings
from xml.etree import ElementTree as ET
from collections import defaultdict
+from conifer.libsystems.evergreen.support import initialize, E1
+from conifer.libsystems.evergreen.opensrf import *
+ at instructors_only
+def item_ils_update(request):
+ """Update item in ILS"""
+ # this works in my tests, need to try more variations
+ # disable in production for now
+ return simple_message(_('testing.'), _('testing.'))
+ token = auth_token(settings.OPENSRF_STAFF_USERID, settings.OPENSRF_STAFF_PW,
+ settings.OPENSRF_STAFF_ORG, settings.OPENSRF_STAFF_WORKSTATION)
+ null = None
+ true = True
+ # barcode will come from form
+ barcode = "31862005297755"
+ barcode_copy = E1(settings.OPENSRF_CN_BARCODE, token, barcode);
+ copy = None
+ if barcode_copy:
+ copy = barcode_copy.get("copy")
+ if copy:
+ detailid = copy['__p'][21]
+ details = E1(settings.OPENSRF_FLESHEDCOPY_CALL, [detailid])
+ print "details", details
+ location = details[0]['__p'][23]['__p'][3]
+ details[0]['__p'][6] = "CIRC"
+ details[0]['__p'][23] = location
+ details[0]['__p'].append(None)
+ details[0]['__p'].append('1')
+ updaterec = E1(settings.OPENSRF_BATCH_UPDATE, token, details,true)
+ print "updaterec", updaterec
+ session_cleanup(token)
+ return simple_message(_('testing.'), _('testing.'))
+
@members_only
def item_detail(request, site_id, item_id):
"""Display an item (however that makes sense)."""
More information about the open-ils-commits
mailing list