--- trunk/lib/WebPAC/Normalize.pm 2005/11/24 11:47:15 125 +++ trunk/lib/WebPAC/Normalize.pm 2005/12/15 17:01:04 252 @@ -11,11 +11,11 @@ =head1 VERSION -Version 0.02 +Version 0.04 =cut -our $VERSION = '0.02'; +our $VERSION = '0.04'; =head1 SYNOPSIS @@ -82,11 +82,15 @@ db => $db_obj, lookup_regex => $lookup->regex, lookup => $lookup_obj, + prefix => 'foobar', ); Parametar C defines user supplied snippets of perl code which can be use with C notation. +C is used to form filename for database record (to support multiple +source files which are joined in one database). + Recommended parametar C is used to enable parsing of lookups in structures. If you pass this parametar, you must also pass C which is C object. @@ -111,6 +115,10 @@ $log->logdie("lookup must be WebPAC::Lookup object") if ($self->{'lookup'} && ! $self->{'lookup'}->isa('WebPAC::Lookup')); + $log->warn("no prefix defined. please check that!") unless ($self->{'prefix'}); + + $log->debug("using lookup regex: ", $self->{lookup_regex}) if ($r && $l); + $self ? return $self : return undef; } @@ -138,12 +146,12 @@ $log->logdie("need unique ID (mfn) in field 000 of record ", sub { Dumper($rec) } ) unless (defined($rec->{'000'})); - my $mfn = $rec->{'000'}->[0] || $log->logdie("field 000 isn't array!"); + my $id = $rec->{'000'}->[0] || $log->logdie("field 000 isn't array!"); my $cache_file; if ($self->{'db'}) { - my $ds = $self->{'db'}->load_ds( $mfn ); + my $ds = $self->{'db'}->load_ds( id => $id, prefix => $self->{prefix} ); $log->debug("load_ds( rec = ", sub { Dumper($rec) }, ") = ", sub { Dumper($ds) }); return $ds if ($ds); $log->debug("cache miss, creating"); @@ -207,7 +215,7 @@ foreach my $type (@types) { # append to previous line? - $log->debug("type: $type ",sub { join(" ",@v) }, $row->{'append'} || 'no append'); + $log->debug("type: $type ",sub { join(" ",@v) }, " ", $row->{'append'} || 'no append'); if ($tag->{'append'}) { # I will delimit appended part with @@ -249,8 +257,9 @@ } $self->{'db'}->save_ds( - id => $mfn, + id => $id, ds => $ds, + prefix => $self->{prefix}, ) if ($self->{'db'}); $log->debug("ds: ", sub { Dumper($ds) }); @@ -454,7 +463,9 @@ # do we have lookups? if ($self->{'lookup'}) { if ($self->{'lookup'}->can('lookup')) { - return $self->{'lookup'}->lookup($format); + my @lookup = $self->{lookup}->lookup($format); + $log->debug('lookup $format', join(", ", @lookup)); + return @lookup; } else { $log->warn("Have lookup object but can't invoke lookup method"); } @@ -668,4 +679,4 @@ =cut -1; # End of WebPAC::DB +1; # End of WebPAC::Normalize