[ZOOM] PyZ3950 & OCLC Worldcat; YAZ & SWIG

Charles Bearden Charles.F.Bearden at uth.tmc.edu
Wed May 26 23:47:11 CEST 2004

Dear ZOOMers,

For a project here at work I need to search OCLC Worldcat via Z39.50.
Because all other project code is in Python, it is best that I do this
in Python.  I must implement the searching under Windows XP (not my
choice).  I have installed Aaron Lav's PyZ3950 Python binding, but it
doesn't like something in OCLC's protocol implementation.  Example code
& exception:

from PyZ3950 import zoom

zhost = 'fsz3950.oclc.org'
port = 210
dbname = 'VOYAGER'
c = zoom.Connection(zhost, port)

Traceback (most recent call last):
  File "C:\Documents and Settings\cbearden\Desktop\tmp\tesp.py", line 9,
in -toplevel-
    c = zoom.Connection(zhost, port)
  File "C:\Python23\Lib\site-packages\PyZ3950\zoom.py", line 198, in
    optionslist = options, **kwauth)
  File "C:\Python23\Lib\site-packages\PyZ3950\z3950.py", line 1020, in
    self.initresp = self.transact (
  File "C:\Python23\Lib\site-packages\PyZ3950\z3950.py", line 1039, in
    (arm, val) = self.read_PDU ()
  File "C:\Python23\Lib\site-packages\PyZ3950\z3950.py", line 868, in
    raise ProtocolError ('ASN1 BER', str(val))
ProtocolError: ('ASN1 BER', "('Saw tag (128, 1) Expecting (32, -1)',

PyZ3950.zoom seems perfectly happy with both LOC and NLM.  Yaz-client
seems perfectly happy with Worldcat.

Is there something I can do to make PyZ3950.zoom get along with OCLC
databases?  Also, is there a way I can supply an RPN query instead of a
CCL query?  From the source code it appears that PyZ3950.zoom.Query
accepts only CCL queries but then builds a (ASN.1 encoded?) RPN query
object from that to send to the server.  I need the flexibility of some
RPN's attributes.

As an alternative, I played briefly with SWIG, hoping to be able to
figure out how to use it to build a Python module from the YAZ ZOOM
interface.  Unfortunately, I don't know C or C++, and so I have only the
merest idea of what belongs in the .swg file that defines the SWIG
interface (zoom.h seems much more complex than the examples used to
illustrate SWIG).  Does anyone have a SWIG interface definition file
that would enable me to build a Python zoom module from YAZ?  I built
and installed yaz-2.0.21 with the latest Cygwin GNU tools on my WinXP

Final trivial note: line 253 of PyZ3950/zoom.py is lacking the variable
that supplies the value for the format string:

            raise ClientNotImplError ('%s queries not supported')
should be
            raise ClientNotImplError ('%s queries not supported' % typ)

Thanks in advance,

Chuck Bearden
Systems Analyst III
School of Health Information Sciences
University of Texas at Houston
713.500.3954 (voice)
713.500.3907 (fax)
Charles.F.Bearden at uth.tmc.edu

More information about the ZOOM mailing list