-Syrup: A Reserves application
-------------------------------
-
-For more information, see
-http://open-ils.org/dokuwiki/doku.php?id=scratchpad:reserves
-
-or contact
-Art Rhyno <artrhyno@uwindsor.ca>
-Graham Fawcett <graham.fawcett@gmail.com>
-
-
-State of the application
-------------------------------
-
-Coming along nicely, thank you! With a bit of patience, you ought to
-be able to get a basic Syrup system running in no time. Integrating it
-with your backend library and other systems will take longer, of
-course.
-
-Required components
-------------------------------
-
-Most likely you will need a Unix-like system: Linux, BSD, or OS X
-ought all to work. Most development and testing is being done on
-Linux. No testing on Windows has been done.
-
-You need Python. Probably Python 2.5, I haven't tested with other
-versions. You also need sqlite3 or another Django-compatible
-database. Sqlite3 is recommended for kicking the tires, PostgreSQL for
-production.
-
-Third-party Python dependencies:
-
- sudo easy_install Django Genshi Babel BabelDjango pexpect
-
-(You'll need 'setuptools' in order to have 'easy_install'.)
-
-Graham has the following versions installed. Not saying you need these
-exact ones, just that they are known to work.
-
- Django-1.0.1_final-py2.5
- Babel-0.9.4-py2.5
- BabelDjango-0.2.2-py2.5
- Genshi-0.5.1-py2.5
- pexpect-2.4-py2.5
-
-You will need 'yaz-client' for the Z39.50 stuff. On Ubuntu, this works:
-
- sudo apt-get install yaz libyaz3
-
-
-Getting this thing to run
-------------------------------
-
-This might work:
-
-* Review settings.py. Maybe you need to edit stuff. Probably not for a
- quick test.
-
-* ./manage.py syncdb
-
-* During syncdb, create yourself a superuser account.
-
-* ./pybabel-extract (currently, this is optional)
-
-* ./manage.py runserver
-
-* visit http://localhost:8000/ and log in.
-
-* create at least one Term and one Department under Admin Options.
-
-* make yourself a course.
-
-* click on all of the links and see what they do.
-
-
-Contents [out of date -- Ed.]
-------------------------------
-
-syrup/ -- the reserves app
-middleware/ -- middleware component to integrate Genshi
-locale/ -- the gettext files
-templates/ -- the Genshi templates
-static/ -- static JS, CSS, image files
-doc/ -- documentation on the app
-
-local_settings.py.in -- a template for local_settings.py
-genshi_support.py -- Genshi template integration
-pybabel-extract -- a "make all" for the i18n files
-babel.cfg -- Babel (i18n) configuration file
-
-The rest is straightforward Django stuff.
-
-
-Customization
-------------------------------
-
-The 'custom' directory contains (or should contain!) all of the bits
-that you really need to customize for your institution. More
-documentation is needed here, but the source code is mostly
+Syrup: A Reserves application\r
+------------------------------\r
+\r
+For more information, see\r
+http://open-ils.org/dokuwiki/doku.php?id=scratchpad:reserves\r
+\r
+or contact\r
+Art Rhyno <artrhyno@uwindsor.ca>\r
+Graham Fawcett <graham.fawcett@gmail.com>\r
+\r
+\r
+State of the application\r
+------------------------------\r
+\r
+Coming along nicely, thank you! With a bit of patience, you ought to\r
+be able to get a basic Syrup system running in no time. Integrating it\r
+with your backend library and other systems will take longer, of\r
+course.\r
+\r
+Required components\r
+------------------------------\r
+\r
+You need Python. Probably Python 2.5, I haven't tested with other\r
+versions. You also need sqlite3 or another Django-compatible\r
+database. Sqlite3 is recommended for kicking the tires, PostgreSQL for\r
+production.\r
+\r
+Third-party Python dependencies:\r
+\r
+ sudo easy_install Django Genshi Babel BabelDjango\r
+\r
+(You'll need 'setuptools' in order to have 'easy_install'.)\r
+\r
+Windows is very similar, see:\r
+\r
+http://groups.google.com/group/syrup-reserves-discuss/web/installing-syrup-in-windows\r
+\r
+Graham has the following versions installed. Not saying you need these\r
+exact ones, just that they are known to work.\r
+\r
+ Django-1.0.1_final-py2.5\r
+ Babel-0.9.4-py2.5\r
+ BabelDjango-0.2.2-py2.5\r
+ Genshi-0.5.1-py2.5\r
+\r
+Getting this thing to run\r
+------------------------------\r
+\r
+This might work:\r
+\r
+* Review settings.py. Maybe you need to edit stuff. Probably not for a\r
+ quick test.\r
+\r
+* ./manage.py syncdb\r
+\r
+Note: don't use the "./" syntax in windows for the commands, e.g.:\r
+\r
+C:\src\syrup\trunk\conifer>manage.py syncdb\r
+\r
+* During syncdb, create yourself a superuser account.\r
+\r
+* ./pybabel-extract (currently, this is optional)\r
+\r
+* ./manage.py runserver\r
+\r
+* visit http://localhost:8000/ and log in.\r
+\r
+* create at least one Term and one Department under Admin Options.\r
+\r
+* make yourself a course.\r
+\r
+* click on all of the links and see what they do.\r
+\r
+\r
+Contents [out of date -- Ed.]\r
+------------------------------\r
+\r
+syrup/ -- the reserves app\r
+middleware/ -- middleware component to integrate Genshi\r
+locale/ -- the gettext files\r
+templates/ -- the Genshi templates\r
+static/ -- static JS, CSS, image files\r
+doc/ -- documentation on the app\r
+\r
+local_settings.py.in -- a template for local_settings.py\r
+genshi_support.py -- Genshi template integration\r
+pybabel-extract -- a "make all" for the i18n files\r
+babel.cfg -- Babel (i18n) configuration file\r
+\r
+The rest is straightforward Django stuff.\r
+\r
+\r
+Customization\r
+------------------------------\r
+\r
+The 'custom' directory contains (or should contain!) all of the bits\r
+that you really need to customize for your institution. More\r
+documentation is needed here, but the source code is mostly\r
well-documented.
\ No newline at end of file
-# 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:
-# Z39.50 for catalogue search,
-# SIP for patron and item_info, and for item checkout and checkin,
-# OpenSRF for extended item info.
-
-# define a @caching decorator to exploit the Django cache. Fixme, move
-# this somewhere else.
-from django.core.cache import cache
-import cPickle
-def caching(prefix, timeout=60):
- def g(func):
- def f(*args):
- # wtf! Django encodes string-values as
- # unicode-strings. That's bad, like stupid-bad! I'm
- # putting explicit utf8-conversions here to make debugging
- # easier if this code dies.
- key = ','.join([prefix] + map(str, args))
- v = cache.get(key)
- if v:
- return cPickle.loads(v.encode('utf-8'))
- else:
- v = func(*args)
- if v:
- cache.set(key, unicode(cPickle.dumps(v), 'utf-8'), timeout)
- return v
- return f
- return g
-
-
-from django.conf import settings
-
-from conifer.libsystems.evergreen.support import initialize
-EG_BASE = 'http://%s/' % settings.EVERGREEN_GATEWAY_SERVER
-try:
- initialize(EG_BASE)
-except:
- import warnings
- warnings.warn('Evergreen inaccessible! Integration will suck eggs!')
-
-from conifer.libsystems.evergreen import item_status as I
-from conifer.libsystems.sip.sipclient import SIP
-from conifer.libsystems.z3950 import yaz_search
-from conifer.libsystems.z3950.marcxml import marcxml_to_dictionary
-
-
-@caching('patroninfo', timeout=300)
-@SIP
-def patron_info(conn, barcode):
- return conn.patron_info(barcode)
-
-@caching('itemstatus', timeout=300)
-@SIP
-def item_status(conn, barcode):
- return conn.item_info(barcode)
-
-@SIP
-def checkout(conn, patron_barcode, item_barcode):
- return conn.checkout(patron_barcode, item_barcode, '')
-
-@SIP
-def checkin(conn, item_barcode):
- return conn.checkin(item_barcode, institution='', location='')
-
-
-@caching('bcbi', timeout=3600)
-def barcode_to_bib_id(barcode):
- return I.barcode_to_bib_id(barcode)
-
-@caching('bccp', timeout=3600)
-def barcode_to_copy(barcode):
- return I.barcode_to_copy(barcode)
-
-@caching('bimx', timeout=3600)
-def bib_id_to_marcxml(bib_id):
- return I.bib_id_to_marcxml(bib_id)
-
-
-def cat_search(query, start=1, limit=10):
- # this is a total hack for conifer. If the query is a Conifer
- # title-detail URL, then return just that one item.
- if query.startswith(EG_BASE):
- results = marcxml_to_dictionary(I.url_to_marcxml(query), multiples=True)
- numhits = len(results)
- else:
- cat_host, cat_db = settings.Z3950_CONFIG
- results, numhits = yaz_search.search(cat_host, cat_db, query, start, limit)
- return results, numhits
+# Our integration-point with back-end library systems.\r
+\r
+# This is a work in progress. I'm trying to separate out the actual\r
+# protocol handlers (in libsystems) from the configuration decicions\r
+# (in settings.py), and use this as sort of a merge-point between\r
+# those two decisions. \r
+\r
+# TODO: write some documentation about the lib_integration interface.\r
+\r
+# Our example configuration: \r
+# Z39.50 for catalogue search, \r
+# SIP for patron and item_info, and for item checkout and checkin,\r
+# OpenSRF for extended item info.\r
+\r
+# define a @caching decorator to exploit the Django cache. Fixme, move\r
+# this somewhere else.\r
+from django.core.cache import cache\r
+import cPickle \r
+def caching(prefix, timeout=60):\r
+ def g(func):\r
+ def f(*args):\r
+ # wtf! Django encodes string-values as\r
+ # unicode-strings. That's bad, like stupid-bad! I'm\r
+ # putting explicit utf8-conversions here to make debugging\r
+ # easier if this code dies.\r
+ key = ','.join([prefix] + map(str, args))\r
+ v = cache.get(key)\r
+ if v:\r
+ return cPickle.loads(v.encode('utf-8'))\r
+ else:\r
+ v = func(*args)\r
+ if v:\r
+ cache.set(key, unicode(cPickle.dumps(v), 'utf-8'), timeout)\r
+ return v\r
+ return f\r
+ return g\r
+\r
+\r
+from django.conf import settings\r
+\r
+from conifer.libsystems.evergreen.support import initialize\r
+EG_BASE = 'http://%s/' % settings.EVERGREEN_GATEWAY_SERVER\r
+try:\r
+ initialize(EG_BASE)\r
+except:\r
+ import warnings\r
+ warnings.warn('Evergreen inaccessible! Integration will suck eggs!')\r
+\r
+from conifer.libsystems.evergreen import item_status as I\r
+from conifer.libsystems.sip.sipclient import SIP\r
+#from conifer.libsystems.z3950 import yaz_search\r
+from conifer.libsystems.z3950.marcxml import marcxml_to_dictionary\r
+\r
+\r
+@caching('patroninfo', timeout=300)\r
+@SIP\r
+def patron_info(conn, barcode):\r
+ return conn.patron_info(barcode)\r
+\r
+@caching('itemstatus', timeout=300)\r
+@SIP\r
+def item_status(conn, barcode):\r
+ return conn.item_info(barcode)\r
+\r
+@SIP\r
+def checkout(conn, patron_barcode, item_barcode):\r
+ return conn.checkout(patron_barcode, item_barcode, '')\r
+\r
+@SIP\r
+def checkin(conn, item_barcode):\r
+ return conn.checkin(item_barcode, institution='', location='')\r
+\r
+\r
+@caching('bcbi', timeout=3600)\r
+def barcode_to_bib_id(barcode):\r
+ return I.barcode_to_bib_id(barcode)\r
+\r
+@caching('bccp', timeout=3600)\r
+def barcode_to_copy(barcode):\r
+ return I.barcode_to_copy(barcode)\r
+\r
+@caching('bimx', timeout=3600)\r
+def bib_id_to_marcxml(bib_id):\r
+ return I.bib_id_to_marcxml(bib_id)\r
+\r
+\r
+def cat_search(query, start=1, limit=10):\r
+ # this is a total hack for conifer. If the query is a Conifer\r
+ # title-detail URL, then return just that one item.\r
+ if query.startswith(EG_BASE):\r
+ results = marcxml_to_dictionary(I.url_to_marcxml(query), multiples=True)\r
+ numhits = len(results)\r
+ else:\r
+ cat_host, cat_db = settings.Z3950_CONFIG\r
+ results, numhits = yaz_search.search(cat_host, cat_db, query, start, limit)\r
+ return results, numhits\r