[open-ils-commits] r252 - in servres/trunk/conifer: . custom libsystems/sip syrup templates/phys (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Apr 2 22:45:32 EDT 2009


Author: gfawcett
Date: 2009-04-02 22:45:30 -0400 (Thu, 02 Apr 2009)
New Revision: 252

Modified:
   servres/trunk/conifer/TODO
   servres/trunk/conifer/custom/lib_integration.py
   servres/trunk/conifer/libsystems/sip/sipclient.py
   servres/trunk/conifer/settings.py
   servres/trunk/conifer/syrup/views.py
   servres/trunk/conifer/templates/phys/checkout.xhtml
Log:
ugly-but-functional SIP patron-check, item-status-check and item checkout.

Needs some configuring at the bottom of settings.py to get the SIP to
work.

Modified: servres/trunk/conifer/TODO
===================================================================
--- servres/trunk/conifer/TODO	2009-04-03 01:31:49 UTC (rev 251)
+++ servres/trunk/conifer/TODO	2009-04-03 02:45:30 UTC (rev 252)
@@ -7,3 +7,6 @@
 * Import of reserves data from Leddy voyager. Laurentian, others?
 
 * Generating barcodes in emails, printable screens? (3 of 9 enough?)
+
+* People should be able to register themselves into open courses.
+  That is, actually become a member of them.

Modified: servres/trunk/conifer/custom/lib_integration.py
===================================================================
--- servres/trunk/conifer/custom/lib_integration.py	2009-04-03 01:31:49 UTC (rev 251)
+++ servres/trunk/conifer/custom/lib_integration.py	2009-04-03 02:45:30 UTC (rev 252)
@@ -1,5 +1,10 @@
 # Our integration-point with back-end library systems.
 
+# This is a work in progress. I'm trying to separate out the actual
+# protocol handlers (in libsystems) from the configuration decicions
+# (in settings.py), and use this as sort of a merge-point between
+# those two decisions. 
+
 # TODO: write some documentation about the lib_integration interface.
 
 # Our example configuration: 
@@ -7,21 +12,28 @@
 # SIP for patron and item_info, and for item checkout and checkin,
 # OpenSRF for extended item info.
 
-from conifer.libsystems.sip import sipclient
+from django.conf import settings
+#LIBINT = settings.LIBRARY_INTEGRATION # more on this later.
 
+from conifer.libsystems.sip.sipclient import SIP
 
-def patron_info(barcode):
-    conn = sipclient.sip_connection()
-    resp = sipclient.sip_connection().patron_info(barcode)
-    conn.close()
-    return resp
 
-def item_info(barcode):
-    conn = sipclient.sip_connection()
-    resp = conn.item_info(barcode)
-    conn.close()
-    return resp
+ at SIP
+def patron_info(conn, barcode):
+    return conn.patron_info(barcode)
 
+ at SIP
+def item_status(conn, barcode):
+    return conn.item_info(barcode)
+
+ at SIP
+def checkout(conn, patron_barcode, item_barcode):
+    return conn.checkout(patron_barcode, item_barcode, '')
+
+ at SIP
+def checkin(conn, item_barcode):
+    return conn.checkin(item_barcode, institution='', location='')
+
     
 
 

Modified: servres/trunk/conifer/libsystems/sip/sipclient.py
===================================================================
--- servres/trunk/conifer/libsystems/sip/sipclient.py	2009-04-03 01:31:49 UTC (rev 251)
+++ servres/trunk/conifer/libsystems/sip/sipclient.py	2009-04-03 02:45:30 UTC (rev 252)
@@ -26,7 +26,7 @@
 from datetime import datetime
 import re
 
-DEBUG = False
+DEBUG = True
 
 # ------------------------------------------------------------
 # helper functions
@@ -259,6 +259,10 @@
             fld_localtime,
             charfield('protocol', default='2.00'),
             fld_INST_ID,
+            optfield('patron_id', FID_PATRON_ID),
+            optfield('item_id', FID_ITEM_ID),
+            optfield('terminal_pwd', FID_TERMINAL_PWD),
+            
             optfield('instname', FID_LIBRARY_NAME),
             field('supported', FID_SUPPORTED_MSGS),
             optfield('ttylocn', FID_TERMINAL_LOCN),
@@ -328,6 +332,28 @@
             ofld_print_line,
             ofld_screen_msg),
 
+    CHECKOUT: message(
+        CHECKOUT,
+        yn('renewals_OK'),
+        yn('no_block'),
+        fld_localtime,
+        fld_localtime,
+        field('inst', FID_INST_ID),
+        field('patron', FID_PATRON_ID),
+        field('item', FID_ITEM_ID),
+        ),
+
+    CHECKIN: message(
+        CHECKIN,
+        yn('is_retry'),
+        fld_localtime,
+        fld_localtime,
+        field('item', FID_ITEM_ID),
+        field('location', FID_CURRENT_LOCN),
+        field('inst', FID_INST_ID),
+        ofld_TERMINAL_PWD,
+        ),
+
     ITEM_INFORMATION : message(
             ITEM_INFORMATION,
             fld_localtime,
@@ -412,6 +438,21 @@
                          'startitem':1, 'enditem':2})
         return msg
 
+    def checkout(self, patron, item, inst=''):
+        msg = self.send(CHECKOUT, RAW, # fixme
+                        {'patron':patron,
+                         'inst': inst,
+                         'item':item})
+        return msg
+
+    def checkin(self, item, institution='', location=''):
+        msg = self.send(CHECKIN, RAW, # fixme
+                        {'inst': institution,
+                         'location':location,
+                         'is_retry':False,
+                         'item':item})
+        return msg
+
     def item_info(self, barcode):
         msg = self.send(ITEM_INFORMATION, ITEM_INFO_RESP,
                         {'item':barcode})
@@ -446,6 +487,15 @@
             raise 'SipLoginError'
         return sip
 
+    # decorator
+    def SIP(fn):
+        def f(*args, **kwargs):
+            conn = sip_connection()
+            resp = fn(conn, *args, **kwargs)
+            conn.close()
+            return resp
+        return f
+
 except ImportError:
     pass
 
@@ -456,7 +506,7 @@
 if __name__ == '__main__':
     from pprint import pprint
 
-    sip = SipClient('localhost', 6001)
+    sip = SipClient('home', 6001)
     resp = sip.login(uid='scclient',
                      pwd='clientpwd', locn='The basement')
     pprint(resp)
@@ -473,9 +523,20 @@
         result = sip.send(ITEM_INFORMATION, ITEM_INFO_RESP,
                           {'item':item})
         print '%-12s: %s' % (item, result['title'] or '????')
-
+        print sip.send(CHECKOUT, RAW,
+                       {'patron':'scclient-2',
+                        'inst': 'UWOLS',
+                        'item':item})
+        print '\n' * 5
     pprint(sip.send(END_PATRON_SESSION, END_SESSION_RESP,
                    {'patron':'scclient',
                     'inst':'UWOLS'}))
 
 
+
+#checked out a book!
+#"{'raw': '121NNY20090402    220912AOconifer|AA21862000380830|AB31862017120995|AJNo great mischief|AH2009-07-31 00:00:00|CK001|\\r'}"
+
+#checked it back in:
+#"{'raw': '101YNN20090402    222519AO|AB31862017120995|AQLeddy Library|AJNo great mischief|AA21862000380830|CK001|\\r'}"
+

Modified: servres/trunk/conifer/settings.py
===================================================================
--- servres/trunk/conifer/settings.py	2009-04-03 01:31:49 UTC (rev 251)
+++ servres/trunk/conifer/settings.py	2009-04-03 02:45:30 UTC (rev 252)
@@ -106,8 +106,27 @@
     'django.contrib.auth.backends.ModelBackend',
 ]
 
+
+# more on this later.
+LIBRARY_INTEGRATION = {
+    'patron_info': 'SIP',
+    'item_status': 'SIP',
+    'item_info'  : 'OpenSRF',
+    'catalogue'  : 'Z39.50',
+}
+
 EVERGREEN_XMLRPC_SERVER = None # evergreen host, for auth, e.g. '192.168.1.10'
 
 if EVERGREEN_XMLRPC_SERVER:
     AUTHENTICATION_BACKENDS.append(
         'conifer.custom.auth_evergreen.EvergreenAuthBackend')
+
+# stuff that I really ought not check into svn...
+#SIP_HOST = ('hostname', 9999)
+#SIP_CREDENTIALS = ('userid', 'password', 'location')
+
+try:
+    # Graham has this right now; it's not official Syrup. Nothing to see here.
+    from private_local_settings import SIP_HOST, SIP_CREDENTIALS
+except:
+    pass

Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py	2009-04-03 01:31:49 UTC (rev 251)
+++ servres/trunk/conifer/syrup/views.py	2009-04-03 02:45:30 UTC (rev 252)
@@ -1241,14 +1241,17 @@
             # also, make sure the barcode actually matches with a
             # known barcode in Syrup. We only checkout what we know
             # about.
-            msg = lib_integration.item_info(item)
+            msg = lib_integration.item_status(item)
             item_descrip = '%s — %s' % (
                 msg['title'], msg['status'])
 
             # do the checkout
+            msg = lib_integration.checkout(patron, item)
+            
             return g.render('phys/checkout.xhtml', step=3, 
                             patron=patron, item=item,
                             patron_descrip=post('patron_descrip'),
+                            checkout_result=msg['raw'],
                             item_descrip=item_descrip)
         elif post('step') == '3':
             # continue after checkout. Go to 'checkout another item'.

Modified: servres/trunk/conifer/templates/phys/checkout.xhtml
===================================================================
--- servres/trunk/conifer/templates/phys/checkout.xhtml	2009-04-03 01:31:49 UTC (rev 251)
+++ servres/trunk/conifer/templates/phys/checkout.xhtml	2009-04-03 02:45:30 UTC (rev 252)
@@ -42,7 +42,7 @@
       </tr>
       <tr py:if="step==3">
 	<th/>
-	<td><b>Success: Item Checked Out (FOR PRETEND! Not doing checkout yet).</b></td>
+	<td><b>${checkout_result}</b></td>
       </tr>
       <tr>
 	<th/>



More information about the open-ils-commits mailing list