stablizing resetter some more
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 8 Jul 2006 19:24:50 +0000 (19:24 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sat, 8 Jul 2006 19:24:50 +0000 (19:24 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4943 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Utils/ScriptRunner.pm

index cf6fd00..7fc6632 100644 (file)
@@ -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) {