[interchange-cvs] interchange - heins modified lib/Vend/Interpolate.pm
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Fri Nov 22 20:47:00 2002
User: heins
Date: 2002-11-23 01:46:00 GMT
Modified: lib/Vend Interpolate.pm
Log:
* Add [loop extended="table::key"] construct to allow retrieving and easily
accessing a hash-extended record in a database.
This is convenience -- you can reference individual elements with
[item-tag object ...][/item-tag] but the syntax is clumsy.
Only accesses a single record, alas, as the possible proliferation
of fields is immense. A hash-based access method could do that, but
is not present yet.
Revision Changes Path
2.130 +34 -2 interchange/lib/Vend/Interpolate.pm
rev 2.130, prev_rev 2.129
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.129
retrieving revision 2.130
diff -u -r2.129 -r2.130
--- Interpolate.pm 14 Nov 2002 19:29:04 -0000 2.129
+++ Interpolate.pm 23 Nov 2002 01:46:00 -0000 2.130
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.129 2002/11/14 19:29:04 mheins Exp $
+# $Id: Interpolate.pm,v 2.130 2002/11/23 01:46:00 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.129 $, 10);
+$VERSION = substr(q$Revision: 2.130 $, 10);
@EXPORT = qw (
@@ -5207,6 +5207,38 @@
$opt->{lr} = 1 unless
defined $opt->{lr}
or $opt->{quoted};
+ }
+ elsif ($opt->{extended}) {
+ ###
+ ### This returns
+ ###
+ my ($view, $tab, $key) = split /:+/, $opt->{extended}, 3;
+ if(! $key) {
+ $key = $tab;
+ $tab = $view;
+ undef $view;
+ }
+ my $id = $tab;
+ $id .= "::$key" if $key;
+ my $meta = Vend::Table::Editor::meta_record($id, $view, $opt->{table});
+
+ if(! $meta) {
+ $opt->{object} = {
+ matches => 1,
+ mv_results => [],
+ mv_field_names => [],
+ };
+ }
+ else {
+ my @keys = grep $_ ne 'code', keys %$meta;
+ unshift @keys, 'code';
+ $opt->{object} = {
+ matches => 1,
+ mv_results => [ [ @{$meta}{@keys} ] ],
+ mv_field_names => \@keys,
+ };
+ }
+ return region($opt, $text);
}
if ($fn = $opt->{fn} || $opt->{mv_field_names}) {