/[webpac2]/trunk/lib/WebPAC/Input.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/Input.pm

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

revision 287 by dpavlin, Sun Dec 18 21:06:51 2005 UTC revision 301 by dpavlin, Mon Dec 19 21:26:04 2005 UTC
# Line 92  sub new { Line 92  sub new {
92          $module =~ s#::#/#g;          $module =~ s#::#/#g;
93          $module .= '.pm';          $module .= '.pm';
94          $log->debug("require low-level module $self->{module} from $module");          $log->debug("require low-level module $self->{module} from $module");
95    
96          require $module;          require $module;
97          eval $self->{module} .'->import';          #eval $self->{module} .'->import';
98    
99          # check if required subclasses are implemented          # check if required subclasses are implemented
100          foreach my $subclass (qw/open_db fetch_rec/) {          foreach my $subclass (qw/open_db fetch_rec init/) {
101                  if ( $self->can($subclass) ) {                  my $n = $self->{module} . '::' . $subclass;
102                          $log->debug("imported $subclass");                  if (! defined &{ $n }) {
103                            my $missing = "missing $subclass in $self->{module}";
104                            $self->{$subclass} = sub { $log->logwarn($missing) };
105                  } else {                  } else {
106                          $log->warn("missing $subclass in $self->{module}");                          $self->{$subclass} = \&{ $n };
107                  }                  }
108          }          }
109    
110          if ($self->can('init')) {          if ($self->{init}) {
111                  $log->debug("calling init");                  $log->debug("calling init");
112                  $self->init(@_);                  $self->{init}->($self, @_);
113          }          }
114    
115          $self->{'code_page'} ||= 'ISO-8859-2';          $self->{'code_page'} ||= 'ISO-8859-2';
# Line 173  sub open { Line 176  sub open {
176          my $code_page = $arg->{'code_page'} || '852';          my $code_page = $arg->{'code_page'} || '852';
177    
178          # store data in object          # store data in object
179          $self->{'code_page'} = $code_page;          $self->{'input_code_page'} = $code_page;
180          foreach my $v (qw/path offset limit/) {          foreach my $v (qw/path offset limit/) {
181                  $self->{$v} = $arg->{$v} if ($arg->{$v});                  $self->{$v} = $arg->{$v} if ($arg->{$v});
182          }          }
# Line 181  sub open { Line 184  sub open {
184          # create Text::Iconv object          # create Text::Iconv object
185          $self->{iconv} = Text::Iconv->new($code_page,$self->{'code_page'});          $self->{iconv} = Text::Iconv->new($code_page,$self->{'code_page'});
186    
187          my ($db, $size) = $self->open_db(          my ($db, $size) = $self->{open_db}->( $self,
188                  path => $arg->{path},                  path => $arg->{path},
189          );          );
190    
# Line 206  sub open { Line 209  sub open {
209          }          }
210    
211          if ($self->{limit}) {          if ($self->{limit}) {
212                  $log->info("limiting to ",$self->{limit}," records");                  $log->debug("limiting to ",$self->{limit}," records");
213                  $limit = $offset + $self->{limit} - 1;                  $limit = $offset + $self->{limit} - 1;
214                  $limit = $size if ($limit > $size);                  $limit = $size if ($limit > $size);
215          }          }
# Line 221  sub open { Line 224  sub open {
224    
225                  $log->debug("position: $pos\n");                  $log->debug("position: $pos\n");
226    
227                  my $rec = $self->fetch_rec( $db, $pos );                  my $rec = $self->{fetch_rec}->($self, $db, $pos );
228    
229                  if (! $rec) {                  if (! $rec) {
230                          $log->warn("record $pos empty? skipping...");                          $log->warn("record $pos empty? skipping...");

Legend:
Removed from v.287  
changed lines
  Added in v.301

  ViewVC Help
Powered by ViewVC 1.1.26