From: gfawcett Date: Fri, 13 Mar 2009 02:06:18 +0000 (+0000) Subject: made PyZ3950 optional. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=75c349a4262cd6f888a213af516828c17e92de3e;p=Syrup.git made PyZ3950 optional. It was hard to install, and we definitely don't have a good dependency story for our beta testers, so just optionalize it for now. The only thing that won't work for the moment is our Z39.50 test code; everything else is good to go. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@169 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index 7d0f3fd..641d84f 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -14,6 +14,7 @@ # tidy. Views/__init__ would import all the other bits: that ought to # satisfy Django. +import warnings from conifer.syrup import models from datetime import datetime from django.contrib.auth import authenticate, login, logout @@ -33,25 +34,35 @@ import django.forms import re import sys -# Graham needs this import hackery to get PyZ3950 working. Presumably -# Art can 'import profile; import lex', so this hack won't run for -# him. +#----------------------------------------------------------------------------- +# Z39.50 Support +# +# This is experimental at this time, and requires some tricky Python +# imports as far as I can tell. For that reason, let's keep the Z39.50 +# support optional for now. If you have Ply and PyZ3950, we'll load +# and use it; if not, no worries, everything else will workk. try: - import profile - import lex - import yacc -except ImportError: - sys.modules['profile'] = sys # just get something called 'profile'; - # it's not actually used. - import ply.lex - import ply.yacc # pyz3950 thinks these are toplevel modules. - sys.modules['lex'] = ply.lex - sys.modules['yacc'] = ply.yacc - -# for Z39.50 support, not sure whether this is the way to go yet but -# as generic as it gets -from PyZ3950 import zoom + # Graham needs this import hackery to get PyZ3950 working. Presumably + # Art can 'import profile; import lex', so this hack won't run for + # him. + try: + import profile + import lex + import yacc + except ImportError: + sys.modules['profile'] = sys # just get something called 'profile'; + # it's not actually used. + import ply.lex + import ply.yacc # pyz3950 thinks these are toplevel modules. + sys.modules['lex'] = ply.lex + sys.modules['yacc'] = ply.yacc + + # for Z39.50 support, not sure whether this is the way to go yet but + # as generic as it gets + from PyZ3950 import zoom +except: + warnings.warn('Could not load Z39.50 support.') #----------------------------------------------------------------------------- # poor-man's logging. Not sure we need more yet.