[interchange-cvs] interchange - jon modified 6 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Mon Apr 12 21:10:14 EDT 2004
User: jon
Date: 2004-04-13 01:10:14 GMT
Modified: lib/Vend Interpolate.pm Dispatch.pm
Modified: dist/test/products tests.asc
Modified: . MANIFEST
Added: code/UserTag values_space.tag
Added: dist/test/pages dump.html
Log:
Flesh out alternate values spaces functionality Mike added on 2002-11-18.
In addition to his mv_values_space CGI setting, there is now a
[values-space] tag for setting the values space for the lifetime of the
current page (its various options are documented in the tag itself), and
[value] and [value-extended] both accept the values_space option to pull
a value out of an alternate space without changing the current one. The
name of the current values space is now stored in $Vend::ValuesSpace,
which is used when optionally copying values from the old to the new
values space in [values-space].
Tests included.
Also added enable_itl option to [value] to make it feature compatible with
[value-extended].
Revision Changes Path
1.1 interchange/code/UserTag/values_space.tag
rev 1.1, prev_rev 1.0
Index: values_space.tag
===================================================================
#
# values-space tag
# $Id: values_space.tag,v 1.1 2004/04/13 01:10:13 jon Exp $
#
# Usage:
#
# [values-space checkout]
# Switches current values space to "checkout" for duration of page.
#
# [values-space name=checkout copy-all=1]
# Same as above, but copies all values from main values space into "checkout"
# values space. (Does not dereference nested data structures.)
#
# [values-space name=checkout copy="lname fname company"]
# Copies only three named values instead of all values.
#
# [values-space name=checkout clear=1]
# Removes all values from values space "checkout", then switches to it.
#
# [values-space]
# [perl] $Tag->values_space() [/perl]
# Returns the name of the current values space (here 'checkout').
#
# [values-space name=""]
# or: [perl] $Tag->values_space('') [/perl]
# Switches back to default values space.
#
# [values-space name="" show=1]
# Switches back to default values space but returns name of previous space.
#
UserTag values-space Order name
UserTag values-space addAttr
UserTag values-space Version $Revision: 1.1 $
UserTag values-space Routine <<EOR
sub {
my ($name, $opt) = @_;
return $Vend::ValuesSpace unless defined $name;
my $old_name = $Vend::ValuesSpace;
my $old_ref;
if ($old_name eq '') {
$old_ref = $Vend::Session->{values};
}
else {
$old_ref = $Vend::Session->{values_repository}{$old_name} ||= {};
}
if ($name eq '') {
$::Values = $Vend::Session->{values};
}
else {
$::Values = $Vend::Session->{values_repository}{$name} ||= {};
}
$Vend::ValuesSpace = $name;
%$::Values = () if $opt->{clear};
my @copy;
if ($opt->{copy_all}) {
@copy = keys %$old_ref;
}
elsif ($opt->{copy}) {
@copy = grep /\S/, split / /, $opt->{copy};
}
$::Values->{$_} = $old_ref->{$_} for @copy;
#Debug("changed values space from $old_name to $name; new contents:\n" . ::uneval($::Values));
return $opt->{show} ? $old_name : '';
}
EOR
2.208 +38 -14 interchange/lib/Vend/Interpolate.pm
rev 2.208, prev_rev 2.207
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.207
retrieving revision 2.208
diff -u -u -r2.207 -r2.208
--- Interpolate.pm 7 Mar 2004 03:14:41 -0000 2.207
+++ Interpolate.pm 13 Apr 2004 01:10:14 -0000 2.208
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.207 2004/03/07 03:14:41 mheins Exp $
+# $Id: Interpolate.pm,v 2.208 2004/04/13 01:10:14 jon Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.207 $, 10);
+$VERSION = substr(q$Revision: 2.208 $, 10);
@EXPORT = qw (
@@ -2448,6 +2448,20 @@
sub tag_value_extended {
my($var, $opt) = @_;
+ my $vspace = $opt->{values_space};
+ my $vref;
+ if (defined $vspace) {
+ if ($vspace eq '') {
+ $vref = $Vend::Session->{values};
+ }
+ else {
+ $vref = $Vend::Session->{values_repository}{$vspace} ||= {};
+ }
+ }
+ else {
+ $vref = $::Values;
+ }
+
my $yes = $opt->{yes} || 1;
my $no = $opt->{'no'} || '';
@@ -2471,7 +2485,7 @@
return $$CGI::put_ref;
}
- my $val = $CGI::values{$var} || $::Values->{$var} || return undef;
+ my $val = $CGI::values{$var} || $vref->{$var} || return undef;
$val =~ s/</</g unless $opt->{enable_html};
$val =~ s/\[/[/g unless $opt->{enable_itl};
@@ -2719,24 +2733,34 @@
sub tag_value {
my($var,$opt) = @_;
#::logDebug("called value args=" . uneval(\@_));
- my($value);
-
local($^W) = 0;
- $::Values->{$var} = $opt->{set} if defined $opt->{set};
- $value = defined $::Values->{$var} ? ($::Values->{$var}) : '';
- if ($value) {
- # Eliminate any Interchange tags
- $value =~ s/\[/[/g;
- }
+
+ my $vspace = $opt->{values_space};
+ my $vref;
+ if (defined $vspace) {
+ if ($vspace eq '') {
+ $vref = $Vend::Session->{values};
+ }
+ else {
+ $vref = $Vend::Session->{values_repository}{$vspace} ||= {};
+ }
+ }
+ else {
+ $vref = $::Values;
+ }
+
+ $vref->{$var} = $opt->{set} if defined $opt->{set};
+
+ my $value = defined $vref->{$var} ? $vref->{$var} : '';
+ $value =~ s/\[/[/g unless $opt->{enable_itl};
if($opt->{filter}) {
$value = filter_value($opt->{filter}, $value, $var);
- $::Values->{$var} = $value unless $opt->{keep};
+ $vref->{$var} = $value unless $opt->{keep};
}
$::Scratch->{$var} = $value if $opt->{scratch};
return '' if $opt->{hide};
return $opt->{default} if ! $value and defined $opt->{default};
- $value =~ s/</</g
- unless $opt->{enable_html};
+ $value =~ s/</</g unless $opt->{enable_html};
return $value;
}
1.38 +3 -3 interchange/lib/Vend/Dispatch.pm
rev 1.38, prev_rev 1.37
Index: Dispatch.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Dispatch.pm,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -u -r1.37 -r1.38
--- Dispatch.pm 9 Apr 2004 20:40:18 -0000 1.37
+++ Dispatch.pm 13 Apr 2004 01:10:14 -0000 1.38
@@ -1,6 +1,6 @@
# Vend::Dispatch - Handle Interchange page requests
#
-# $Id: Dispatch.pm,v 1.37 2004/04/09 20:40:18 jon Exp $
+# $Id: Dispatch.pm,v 1.38 2004/04/13 01:10:14 jon Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 2002 Mike Heins <mike at perusion.net>
@@ -26,7 +26,7 @@
package Vend::Dispatch;
use vars qw($VERSION);
-$VERSION = substr(q$Revision: 1.37 $, 10);
+$VERSION = substr(q$Revision: 1.38 $, 10);
use POSIX qw(strftime);
use Vend::Util;
@@ -1300,8 +1300,8 @@
$Vend::Calc_initialized = 0;
$CGI::values{mv_session_id} = $Vend::Session->{id} = $Vend::SessionID;
if(my $vspace = $CGI::values{mv_values_space}) {
- $Vend::Session->{values_repository} ||= {};
$::Values = $Vend::Session->{values_repository}{$vspace} ||= {};
+ $Vend::ValuesSpace = $vspace;
}
if($Vend::Cfg->{CookieLogin} and ! $Vend::Session->{logged_in}) {
2.17 +37 -8 interchange/dist/test/products/tests.asc
rev 2.17, prev_rev 2.16
Index: tests.asc
===================================================================
RCS file: /var/cvs/interchange/dist/test/products/tests.asc,v
retrieving revision 2.16
retrieving revision 2.17
diff -u -u -r2.16 -r2.17
--- tests.asc 11 Apr 2004 16:23:06 -0000 2.16
+++ tests.asc 13 Apr 2004 01:10:14 -0000 2.17
@@ -2583,20 +2583,49 @@
%%
Test $db->set_slice() and $db->set_field()
%%%
-999999
+000155
%%
-[the test] [perl]
-# Make this come out right
-return 'The expected result as a regex.';
-[/perl]
+[values-space clear=1 name=nouveau]
+[values-space clear=1 name=nuevo]
+[values-space name='']
+
+[calcn]
+ $Values->{val1} = 'muy bueno';
+ $Values->{val2} = "running\0walking\0diving";
+ $Values->{val3} = undef;
+ $Values->{val4} = ' ([<->]) ';
+ return;
+[/calcn]
+
+1:[value name=val3 set="very good"]:
+2:[value val1]:[value name=val1 values-space=nouveau]:
+[values-space nouveau]3:[value-extended name=val2 joiner=,]:[value-extended values-space='' name=val2 joiner=,]:
+4:[value name=val1 set=0]:[if value val1]yes[else]no[/else][/if]:[value val1]:
+5:[value name=val1 values-space=""]:
+6:[values-space name=nuevo copy=" val3 nichts " show=1]:[values-space]:
+7:[value val1]:[value val3]:[value nichts]:
+8:[value name=val1 values-space=nouveau]:[value name=val1 values-space='']:[value default=hey name=val1]:
+9:[values-space name="" show=1]:
+10:[value name=val4 enable_html=1 enable_itl=1]:[value name=val4 filter=strip]:
+11:[value name=val4 filter=strip]:[value name=val4 enable_html=1 enable_itl=1]:
%%
-The expected result as a regex.
+1:very good:
+2:muy bueno::
+3::running,walking,diving:
+4:0:no:0:
+5:muy bueno:
+6:nouveau:nuevo:
+7::::
+8:0:muy bueno:hey:
+9:nuevo:
+10: \(\[<->]\) :\([<->]\):
+11:\([<->]\):\([<->]\):
%%
-The NOT expected result.
+
%%
%%
-Skeleton test.
+Test value, value-extended, and values-space tags.
%%%
999999
%%
1.1 interchange/dist/test/pages/dump.html
rev 1.1, prev_rev 1.0
Index: dump.html
===================================================================
<pre>[dump]</pre>
2.135 +2 -1 interchange/MANIFEST
rev 2.135, prev_rev 2.134
Index: MANIFEST
===================================================================
RCS file: /var/cvs/interchange/MANIFEST,v
retrieving revision 2.134
retrieving revision 2.135
diff -u -u -r2.134 -r2.135
--- MANIFEST 12 Apr 2004 00:50:14 -0000 2.134
+++ MANIFEST 13 Apr 2004 01:10:14 -0000 2.135
@@ -197,6 +197,7 @@
code/UserTag/ups_query.tag
code/UserTag/usertrack.tag
code/UserTag/usps_query.tag
+code/UserTag/values_space.tag
code/UserTag/var.tag
code/UserTag/weight.tag
code/Widget/gpg_keys.widget
@@ -1278,7 +1279,6 @@
Makefile.PL
MANIFEST
MANIFEST.SKIP
-META.yml Module meta-data (added by MakeMaker)
README
README.cvs
README.debian
@@ -1373,6 +1373,7 @@
SPECS/interchange-init
SPECS/interchange-logrotate
SPECS/interchange-wrapper
+SPECS/interchange.cfg.patch
SPECS/interchange.spec
test.pl
UPGRADE
More information about the interchange-cvs
mailing list