[interchange-cvs] interchange - heins modified 4 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Mon Jul 19 18:26:00 EDT 2004
User: heins
Date: 2004-07-19 22:26:00 GMT
Modified: lib/Vend Config.pm Interpolate.pm Scan.pm Search.pm
Log:
A few Search enhancements.
* Add ability to save search paging files in the SessionDB when using
DBI sessions. This obviates the need for an NFS-shared tmp/ directory
when sharing accross multiple servers.
Requires setting in catalog.cfg:
MoreDB Yes
Setting this to "Yes" if not using DBI sessions will cause errors.
* Allow passing of mv_no_more (nm) parameter which states that no more
should be done. This is particularly useful for searches like are done
in the "random" component, where we have a random=N with a ml=foo.
That always means a more save, which adds overhead.
Causes save_more to return true without saving.
TODO: Examine automatically adding to [loop ...] lists that don't have
more=1 passed as an option.
* Add ability to save search paging files that are non-session-specific
in a query tag. This allows:
[timed-build force=1 file="timed/[cgi letter][cgi mv_first_match]"]
[query
list=1
mv_more_id=nsession
more=1
ml=10
sql="SELECT * FROM products where description like '[cgi letter]%'"
]
....
[/query]
[/timed-build]
A completely duplicatable paged list is saved with a minimum of overhead;
each paging is done only once and the [more] will use a common source.
TODO: make sure this works with the prefix paging stuff...
Revision Changes Path
2.143 +3 -2 interchange/lib/Vend/Config.pm
rev 2.143, prev_rev 2.142
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.142
retrieving revision 2.143
diff -u -r2.142 -r2.143
--- Config.pm 16 Jul 2004 23:49:06 -0000 2.142
+++ Config.pm 19 Jul 2004 22:26:00 -0000 2.143
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.142 2004/07/16 23:49:06 jon Exp $
+# $Id: Config.pm,v 2.143 2004/07/19 22:26:00 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -48,7 +48,7 @@
use Vend::File;
use Vend::Data;
-$VERSION = substr(q$Revision: 2.142 $, 10);
+$VERSION = substr(q$Revision: 2.143 $, 10);
my %CDname;
my %CPname;
@@ -422,6 +422,7 @@
['SessionType', undef, 'File'],
['SessionDatabase', 'relative_dir', 'session'],
['SessionLockFile', undef, 'etc/session.lock'],
+ ['MoreDB', 'yesno', 'No'],
['DatabaseDefault', 'hash', ''],
['DatabaseAuto', 'dbauto', ''],
['DatabaseAutoIgnore', 'regex', ''],
2.215 +3 -2 interchange/lib/Vend/Interpolate.pm
rev 2.215, prev_rev 2.214
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.214
retrieving revision 2.215
diff -u -r2.214 -r2.215
--- Interpolate.pm 15 Jul 2004 17:20:41 -0000 2.214
+++ Interpolate.pm 19 Jul 2004 22:26:00 -0000 2.215
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.214 2004/07/15 17:20:41 mheins Exp $
+# $Id: Interpolate.pm,v 2.215 2004/07/19 22:26:00 mheins 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.214 $, 10);
+$VERSION = substr(q$Revision: 2.215 $, 10);
@EXPORT = qw (
@@ -4825,6 +4825,7 @@
mv_results => $ary,
mv_field_hash => $nh,
mv_return_fields => $na,
+ mv_more_id => $opt->{mv_more_id},
matches => scalar @$ary,
};
2.26 +5 -3 interchange/lib/Vend/Scan.pm
rev 2.26, prev_rev 2.25
Index: Scan.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Scan.pm,v
retrieving revision 2.25
retrieving revision 2.26
diff -u -r2.25 -r2.26
--- Scan.pm 30 Jul 2003 04:00:45 -0000 2.25
+++ Scan.pm 19 Jul 2004 22:26:00 -0000 2.26
@@ -1,6 +1,6 @@
# Vend::Scan - Prepare searches for Interchange
#
-# $Id: Scan.pm,v 2.25 2003/07/30 04:00:45 mheins Exp $
+# $Id: Scan.pm,v 2.26 2004/07/19 22:26:00 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -30,7 +30,7 @@
perform_search
);
-$VERSION = substr(q$Revision: 2.25 $, 10);
+$VERSION = substr(q$Revision: 2.26 $, 10);
use strict;
use Vend::Util;
@@ -107,6 +107,7 @@
mv_unique
mv_more_matches
mv_value
+ mv_mo_more
mv_next_search
mv_search_reference
prefix
@@ -157,6 +158,7 @@
ne mv_negate
ng mv_negate
nh mv_no_hide
+ nm mv_no_more
np mv_nextpage
ns mv_next_search
nu mv_numeric
@@ -208,7 +210,7 @@
mv_column_op => \&_array,
mv_coordinate => \&_yes,
mv_no_hide => \&_yes,
-
+ mv_no_more => \&_yes,
mv_field_names => \&_array,
mv_spelling_errors => sub { my $n = int($_[1]); $n < 8 ? $n : 1; },
mv_dict_limit => \&_dict_limit,
2.24 +43 -13 interchange/lib/Vend/Search.pm
rev 2.24, prev_rev 2.23
Index: Search.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Search.pm,v
retrieving revision 2.23
retrieving revision 2.24
diff -u -r2.23 -r2.24
--- Search.pm 7 Jun 2004 03:09:36 -0000 2.23
+++ Search.pm 19 Jul 2004 22:26:00 -0000 2.24
@@ -1,6 +1,6 @@
# Vend::Search - Base class for search engines
#
-# $Id: Search.pm,v 2.23 2004/06/07 03:09:36 mheins Exp $
+# $Id: Search.pm,v 2.24 2004/07/19 22:26:00 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -22,7 +22,7 @@
package Vend::Search;
-$VERSION = substr(q$Revision: 2.23 $, 10);
+$VERSION = substr(q$Revision: 2.24 $, 10);
use strict;
use vars qw($VERSION);
@@ -350,14 +350,34 @@
my $id = $s->{mv_more_id} || $s->{mv_session_id};
$id .= ".$s->{mv_cache_key}";
- my $file = Vend::Util::get_filename($id);
-#::logDebug("more_matches: $id from $file");
-
+ my $file;
my $obj;
eval {
- $obj = Vend::Util::eval_file($file);
+ if($Vend::Cfg->{MoreDB}) {
+#::logDebug("more_matches: $id from $Vend::Cfg->{SessionDB}");
+ eval {
+ my $db = Vend::Util::dbref($Vend::Cfg->{SessionDB});
+ $obj = Vend::Util::evalr( $db->field($id,'session') );
+ };
+ $@ and return $s->search_error(
+ "Object saved wrong in session DB for search ID %s.",
+ $id,
+ );
+ }
+ else {
+ $file = Vend::Util::get_filename($id);
+#::logDebug("more_matches: $id from $file");
+ eval {
+ $obj = Vend::Util::eval_file($file);
+ };
+ $@ and return $s->search_error(
+ "Object saved wrong in %s for search ID %s.",
+ $file,
+ $id,
+ );
+ }
};
- $@ and return $s->search_error("Object saved wrong in $file for search ID $id.");
+
for(qw/mv_cache_key mv_matchlimit /) {
$obj->{$_} = $s->{$_};
}
@@ -1117,6 +1137,7 @@
sub save_more {
my($s, $out) = @_;
+ return 1 if $s->{mv_no_more};
return if $MVSAFE::Safe;
my $file;
delete $s->{dbref} if defined $s->{dbref};
@@ -1137,15 +1158,24 @@
more_alpha($s,$out);
}
- $file = Vend::Util::get_filename($id);
-#::logDebug("save_more: $id to $file.");
my $new = { %$s };
- $new->{mv_results} = $out;
delete $new->{search_routines};
+ $new->{mv_results} = $out;
+
+ if($Vend::Cfg->{MoreDB}) {
+#::logDebug("save_more: $id to Session DB.");
#::logDebug("save_more:object:" . ::uneval($new));
- eval {
- Vend::Util::uneval_file($new, $file);
- };
+ my $db = Vend::Util::dbref($Vend::Cfg->{SessionDB});
+ $db->set_field($id, 'session', Vend::Util::uneval_fast($new));
+ }
+ else {
+#::logDebug("save_more: $id to $file.");
+#::logDebug("save_more:object:" . ::uneval($new));
+ $file = Vend::Util::get_filename($id);
+ eval {
+ Vend::Util::uneval_file($new, $file);
+ };
+ }
$@ and return $s->search_error("failed to store more matches");
return 1;
}
More information about the interchange-cvs
mailing list