Merge branch 'eval-code'
authorDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 17 Jun 2010 16:46:26 +0000 (18:46 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 17 Jun 2010 16:46:26 +0000 (18:46 +0200)
README
lib/MojoFacets/Data.pm
templates/actions/view.html.ep

diff --git a/README b/README
index 1d55870..a8f26d5 100644 (file)
--- a/README
+++ b/README
@@ -44,18 +44,18 @@ any other dataset which has same unique values you can use helper script:
 
 Modify your data using perl snippets
 
-Experimental REPL console supports perl snippets which get $rec hash which is one
+Experimental REPL console supports perl snippets which get $row hash which is one
 element from your dataset. All values are repetable, so you always have to create
 array of values if you are creating new columns, even for single value.
 
 * generate new columns with number of elements in some other column
 
-  $rec->{count} = [ $#{ $rec->{original} } + 1 ];
+  $row->{count} = [ $#{ $row->{original} } + 1 ];
 
 * generate century column from year
 
-  foreach my $year ( @{ $rec->{Year} } ) {
-    push @{ $rec->{century} }, int($year/100)+1;
+  foreach my $year ( @{ $row->{Year} } ) {
+    push @{ $row->{century} }, int($year/100)+1;
   }
 
 * modify existing column
index 96fb144..ba64550 100644 (file)
@@ -615,7 +615,7 @@ sub items {
 
        if ( $code && ( $test || $commit ) ) {
                # XXX find columns used in code snippet and show them to user
-               foreach my $column ( $code =~ m/\$rec->{(.+?)}/g ) {
+               foreach my $column ( $code =~ m/\$row->{(.+?)}/g ) {
                        if ( $column =~ s/^(['"])// ) {
                                $column =~ s/$1$//;
                        }
@@ -633,7 +633,7 @@ sub items {
                warn "# commit on ", $#$filtered + 1, " items:\n$code\n";
                foreach ( 0 .. $#$filtered ) {
                        my $i = $filtered->[$_];
-                       my $rec = $data->{items}->[$i];
+                       my $row = $data->{items}->[$i];
                        eval $code;
                }
        }
@@ -645,19 +645,19 @@ sub items {
                last unless defined $filtered->[$i];
                $i = $from_end - $i if $from_end;
                my $id = $filtered->[$i];
-               my $rec = $data->{items}->[ $id ];
-               $rec->{_row_id} ||= $id;
+               my $row = $data->{items}->[ $id ];
                if ( $code && $test ) {
-                       $rec = Storable::dclone $rec;
+                       $row = Storable::dclone $row;
                        eval $code;
                        if ( $@ ) {
                                warn "ERROR evaling\n$code\n$@";
                                $self->stash('eval_error', $@) if $@;
                        } else {
-                               warn "EVAL ",dump($rec);
+                               warn "EVAL ",dump($row);
                        }
                }
-               push @$sorted_items, $rec;
+               $row->{_row_id} ||= $id;
+               push @$sorted_items, $row;
        }
 
        warn "# sorted_items ", $#$sorted_items + 1, " offset $offset limit $limit order $sort";
index eaf50ab..4111df2 100644 (file)
@@ -1,8 +1,8 @@
 % layout 'default';
 
 % my $action = $uid;
-% $action =~ s/^.+\.([^\.]+)$/$1/;
-% $action = url_for( controller => 'data', action => $action );
+% $action =~ s!\.!/!g;
+% $action =~ s!^\d+/\d+!!;
 <form method=post action=<%= $action %>>
 <input type=submit value="<%= $action %>">
 <tt><%= $uid %></tt>