From: miker Date: Sat, 8 Jul 2006 19:24:50 +0000 (+0000) Subject: stablizing resetter some more X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=971d29228138e0a0efb7cbe22d63128eb9609b96;p=Evergreen.git stablizing resetter some more git-svn-id: svn://svn.open-ils.org/ILS/trunk@4943 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm b/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm index cf6fd00864..7fc6632cf7 100644 --- a/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm +++ b/Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm @@ -82,6 +82,14 @@ sub init { sub { $self->_parse_xml_string(@_); } ); + for my $e ( @{$self->{_env}} ) { + $self->insert( @$e{ qw/key value readonly/ } => 1 ); + } + + for my $e ( @{$self->{_methods}} ) { + $self->insert_method( @$e{ qw/key name meth/ } => 1 ); + } + $self->load_lib($_) for @{$self->{libs}}; return $self; @@ -124,10 +132,6 @@ sub run { $file = $self->{file}; } - my $js = $self->context; - - - $self->refresh_context if ($self->reset_count && $self->runs > $self->reset_count); @@ -141,6 +145,8 @@ sub run { return 0; } + my $js = $self->context; + my $res = ''; { local $/ = undef; @@ -232,16 +238,21 @@ sub retrieve { } sub insert_method { - my( $self, $obj_key, $meth_name, $sub ) = @_; + my( $self, $obj_key, $meth_name, $sub, $stop) = @_; + + push @{$self->{_methods}}, { key => $obj_key => name => $meth_name, meth => $sub } unless ($stop); + my $obj = $self->context->object_by_path( $obj_key ); $self->context->function_set( $meth_name, $sub, $obj ) if $obj; } sub insert { - my( $self, $key, $val, $RO ) = @_; + my( $self, $key, $val, $RO, $stop ) = @_; return unless defined($key); + push @{$self->{_env}}, { key => $key => value => $val, readonly => $RO } unless ($stop); + if (ref($val) =~ /^Fieldmapper/o) { $self->insert_fm($key, $val, $RO); } elsif (ref($val) and $val =~ /ARRAY/o) {