From 7775c1094c9b0288b2208925f0250356441f6bfd Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 9 Mar 2006 12:57:19 +0000 Subject: [PATCH] Release 1.03 (connection constructor allows additional option arguments) --- Changes | 7 ++++++- META.yml | 3 ++- lib/Net/Z3950/ZOOM.pm | 4 ++-- lib/ZOOM.pm | 15 ++++++++++++--- lib/ZOOM.pod | 16 ++++++++++++++-- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/Changes b/Changes index 315ca5b..3b87129 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,12 @@ -$Id: Changes,v 1.20 2006-03-09 11:36:49 mike Exp $ +$Id: Changes,v 1.21 2006-03-09 12:57:19 mike Exp $ Revision history for Perl extension Net::Z3950::ZOOM. +1.03 Thu Mar 9 12:55:23 GMT 2006 + - Allow additional key => value pairs as arguments to the + ZOOM::Connectoion constructor; these are added as Connection + options before the protocol connection is forged. + 1.02 Thu Mar 9 11:36:55 GMT 2006 - Add interface to yaz_version(). - Emit big warning at startup time if YAZ version is less than diff --git a/META.yml b/META.yml index 31b9dce..700a6cf 100644 --- a/META.yml +++ b/META.yml @@ -1,10 +1,11 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Net-Z3950-ZOOM -version: 0.01 +version: 1.02 version_from: lib/Net/Z3950/ZOOM.pm installdirs: site requires: + MARC::Record: 1.38 distribution_type: module generated_by: ExtUtils::MakeMaker version 6.17 diff --git a/lib/Net/Z3950/ZOOM.pm b/lib/Net/Z3950/ZOOM.pm index 40b9492..56a678f 100644 --- a/lib/Net/Z3950/ZOOM.pm +++ b/lib/Net/Z3950/ZOOM.pm @@ -1,4 +1,4 @@ -# $Id: ZOOM.pm,v 1.10 2006-01-31 16:13:05 mike Exp $ +# $Id: ZOOM.pm,v 1.11 2006-03-09 12:57:19 mike Exp $ package Net::Z3950::ZOOM; @@ -6,7 +6,7 @@ use 5.008; use strict; use warnings; -our $VERSION = '1.02'; +our $VERSION = '1.03'; require XSLoader; XSLoader::load('Net::Z3950::ZOOM', $VERSION); diff --git a/lib/ZOOM.pm b/lib/ZOOM.pm index 27ad75d..60007af 100644 --- a/lib/ZOOM.pm +++ b/lib/ZOOM.pm @@ -1,4 +1,4 @@ -# $Id: ZOOM.pm,v 1.26 2006-02-10 16:24:34 mike Exp $ +# $Id: ZOOM.pm,v 1.27 2006-03-09 12:57:19 mike Exp $ use strict; use warnings; @@ -7,7 +7,6 @@ use Net::Z3950::ZOOM; package ZOOM; - # Member naming convention: hash-element names which begin with an # underscore represent underlying ZOOM-C object descriptors; those # which lack them represent Perl's ZOOM objects. (The same convention @@ -275,7 +274,7 @@ package ZOOM::Connection; sub new { my $class = shift(); - my($host, $port) = @_; + my($host, $port, @options) = @_; my $_conn = Net::Z3950::ZOOM::connection_new($host, $port || 0); my $conn = bless { @@ -283,6 +282,16 @@ sub new { port => $port, _conn => $_conn, }; + + while (@options >= 2) { + my $key = shift(@options); + my $val = shift(@options); + $conn->option($key, $val); + } + + die "Odd number of options specified" + if @options; + $conn->_check(); return $conn; } diff --git a/lib/ZOOM.pod b/lib/ZOOM.pod index 51d6023..e2aafec 100644 --- a/lib/ZOOM.pod +++ b/lib/ZOOM.pod @@ -1,4 +1,4 @@ -# $Id: ZOOM.pod,v 1.29 2006-02-20 11:30:58 mike Exp $ +# $Id: ZOOM.pod,v 1.30 2006-03-09 12:57:19 mike Exp $ use strict; use warnings; @@ -11,7 +11,8 @@ ZOOM - Perl extension implementing the ZOOM API for Information Retrieval use ZOOM; eval { - $conn = new ZOOM::Connection($host, $port) + $conn = new ZOOM::Connection($host, $port, + databaseName => "mydb"); $conn->option(preferredRecordSyntax => "usmarc"); $rs = $conn->search_pqf('@attr 1=4 dinosaur'); $n = $rs->size(); @@ -159,6 +160,9 @@ http://zoom.z3950.org/api/zoom-current.html#3.2 $conn = new ZOOM::Connection("indexdata.dk:210/gils"); $conn = new ZOOM::Connection("tcp:indexdata.dk:210/gils"); $conn = new ZOOM::Connection("http:indexdata.dk:210/gils"); + $conn = new ZOOM::Connection("indexdata.dk", 210, + databaseName => "mydb", + preferredRecordSyntax => "marc"); Creates a new Connection object, and immediately connects it to the specified server. If you want to make a new Connection object but @@ -170,6 +174,14 @@ argument. In the former case, the arguments are the name and port number of the Z39.50 server to connect to; in the latter case, the single argument is a YAZ service-specifier string of the form +When the two-option form is used (which may be done using a vacuous +second argument of zero), any number of additional argument pairs may +be provided, which are interpreted as key-value pairs to be set as +options after the Connection object is created but before it is +connected to the server. This is a convenient way to set options, +including those that must be set before connecting such as +authentication tokens. + =over 4 =item -- 1.7.10.4