/[webpac2]/trunk/lib/WebPAC/Store.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/WebPAC/Store.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 714 by dpavlin, Tue Sep 26 12:47:52 2006 UTC revision 715 by dpavlin, Tue Sep 26 14:03:12 2006 UTC
# Line 14  WebPAC::Store - Store WebPAC data on dis Line 14  WebPAC::Store - Store WebPAC data on dis
14    
15  =head1 VERSION  =head1 VERSION
16    
17  Version 0.11  Version 0.12
18    
19  =cut  =cut
20    
21  our $VERSION = '0.11';  our $VERSION = '0.12';
22    
23  =head1 SYNOPSIS  =head1 SYNOPSIS
24    
# Line 258  sub save_ds { Line 258  sub save_ds {
258    
259  }  }
260    
261    =head2 load_lookup
262    
263      $data = $db->load_lookup(
264            database => $database,
265            input => $input,
266            key => $key,
267      );
268    
269    =cut
270    
271    sub load_lookup {
272            my $self = shift;
273            my $args = {@_};
274    
275            my $log = $self->_get_logger;
276    
277            foreach my $r (qw/input key/) {
278                    $log->logconfess("need '$r'") unless defined($args->{$r});
279            }
280    
281            my $database = $args->{database} || $self->{database} || $log->logconfess("no database?");
282    
283            my $path = $self->{path} . "/lookup/$database/" . $args->{input} . '/' . $args->{key};
284    
285            if (! -e $path) {
286                    $log->warn("lookup $path doesn't exist, skipping");
287                    return;
288            }
289    
290            if (my $data = retrieve($path)) {
291                    $log->info("loaded lookup $path");
292                    return $data;
293            } else {
294                    $log->logwarn("can't load lookup $database/", $args->{input}, "/", $args->{key}, " from $path: $!");
295                    return undef;
296            }
297    }
298    
299  =head2 save_lookup  =head2 save_lookup
300    
301    $db->save_lookup(    $db->save_lookup(
# Line 291  sub save_lookup { Line 329  sub save_lookup {
329                  $log->info("saved lookup $path");                  $log->info("saved lookup $path");
330                  return 1;                  return 1;
331          } else {          } else {
332                  $log->logwarn("can't store lookup $database/", $args->{input}, "/", $args->{key}, " in $path: $!");                  $log->logwarn("can't save lookup $database/", $args->{input}, "/", $args->{key}, " in $path: $!");
333                  return undef;                  return undef;
334          }          }
335  }  }

Legend:
Removed from v.714  
changed lines
  Added in v.715

  ViewVC Help
Powered by ViewVC 1.1.26