[interchange-cvs] interchange - heins modified lib/Vend/Interpolate.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Thu Nov 14 14:30:01 2002
User: heins
Date: 2002-11-14 19:29:04 GMT
Modified: lib/Vend Interpolate.pm
Log:
* Add "calculated" filter which allows a calculated field:
return $CGI->{cost} * $Variable->{COST_TO_PRICE_RATIO};
Must come from a database (never a CGI, of course). Specified
like lookup:
calculated.mv_metadata.field.formula::cost
Revision Changes Path
2.129 +14 -2 interchange/lib/Vend/Interpolate.pm
rev 2.129, prev_rev 2.128
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.128
retrieving revision 2.129
diff -u -r2.128 -r2.129
--- Interpolate.pm 9 Nov 2002 06:02:03 -0000 2.128
+++ Interpolate.pm 14 Nov 2002 19:29:04 -0000 2.129
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.128 2002/11/09 06:02:03 mheins Exp $
+# $Id: Interpolate.pm,v 2.129 2002/11/14 19:29:04 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -27,7 +27,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.128 $, 10);
+$VERSION = substr(q$Revision: 2.129 $, 10);
@EXPORT = qw (
@@ -856,6 +856,18 @@
'cgi' => sub { return $CGI::values{$_[0]}; },
'filesafe' => sub {
return Vend::Util::escape_chars(shift);
+ },
+ 'calculated' => sub {
+ my ($val, $tag, $table, $column, $key, $indirect) = @_;
+ $key = $CGI::values{$indirect}
+ if $indirect;
+ my $code = tag_data($table, $column, $key);
+ $code =~ s/\r/\n/g;
+#::logDebug("calculated code=$code");
+ $s = $val;
+ my $result = $ready_safe->reval($code);
+#::logDebug("calculated result='$result'");
+ return $result;
},
'mime_type' => sub {
return Vend::Util::mime_type(shift);