[open-ils-commits] r169 - servres/trunk/conifer/syrup (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Mar 12 22:06:19 EDT 2009


Author: gfawcett
Date: 2009-03-12 22:06:18 -0400 (Thu, 12 Mar 2009)
New Revision: 169

Modified:
   servres/trunk/conifer/syrup/views.py
Log:
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.


Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py	2009-03-13 01:57:31 UTC (rev 168)
+++ servres/trunk/conifer/syrup/views.py	2009-03-13 02:06:18 UTC (rev 169)
@@ -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 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
+    # 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
+    # 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.



More information about the open-ils-commits mailing list