[interchange-cvs] interchange - heins modified 5 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Sat Mar 5 23:14:08 EST 2005
User: heins
Date: 2005-03-06 04:14:08 GMT
Modified: lib/Vend Config.pm File.pm Interpolate.pm Scan.pm Search.pm
Log:
* Add "permanent more" feature so that you can create pageable searches
that are shared between people and are cacheable by search engines.
* To activate, put in search URL/form:
pm=1 or mv_more_permanent=1
* To activate in [query ...], use pm=1.
* Changes hashing to two levels so that it will handle larger sets of
searches.
* Depends on consistent spacing of queries, caches query for
mv_cache_key that determines location. The change of a single
bit of whitespace will change the key!
* When your data changes, a saved search could be wrong when referenced
from a bookmark/saved link and no initializing search has been done.
* WARNING: Could generate very large file sets, watch your inodes!
Revision Changes Path
2.157 +3 -2 interchange/lib/Vend/Config.pm
rev 2.157, prev_rev 2.156
Index: Config.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Config.pm,v
retrieving revision 2.156
retrieving revision 2.157
diff -u -r2.156 -r2.157
--- Config.pm 14 Feb 2005 06:33:16 -0000 2.156
+++ Config.pm 6 Mar 2005 04:14:07 -0000 2.157
@@ -1,6 +1,6 @@
# Vend::Config - Configure Interchange
#
-# $Id: Config.pm,v 2.156 2005/02/14 06:33:16 danb Exp $
+# $Id: Config.pm,v 2.157 2005/03/06 04:14:07 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -49,7 +49,7 @@
use Vend::File;
use Vend::Data;
-$VERSION = substr(q$Revision: 2.156 $, 10);
+$VERSION = substr(q$Revision: 2.157 $, 10);
my %CDname;
my %CPname;
@@ -419,6 +419,7 @@
['History', 'integer', 0],
['OrderReport', undef, 'etc/report'],
['ScratchDir', 'relative_dir', 'tmp'],
+ ['PermanentDir', 'relative_dir', 'perm'],
['SessionDB', undef, ''],
['SessionType', undef, 'File'],
['SessionDatabase', 'relative_dir', 'session'],
2.15 +12 -3 interchange/lib/Vend/File.pm
rev 2.15, prev_rev 2.14
Index: File.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/File.pm,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -r2.14 -r2.15
--- File.pm 3 Dec 2003 17:04:26 -0000 2.14
+++ File.pm 6 Mar 2005 04:14:08 -0000 2.15
@@ -1,6 +1,6 @@
# Vend::File - Interchange file functions
#
-# $Id: File.pm,v 2.14 2003/12/03 17:04:26 jon Exp $
+# $Id: File.pm,v 2.15 2005/03/06 04:14:08 mheins Exp $
#
# Copyright (C) 2002-2003 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -53,7 +53,7 @@
use Vend::Util;
use subs qw(logError logGlobal);
use vars qw($VERSION @EXPORT @EXPORT_OK $errstr);
-$VERSION = substr(q$Revision: 2.14 $, 10);
+$VERSION = substr(q$Revision: 2.15 $, 10);
sub writefile {
my($file, $data, $opt) = @_;
@@ -359,7 +359,16 @@
my $i;
$levels = 1 unless defined $levels;
$chars = 1 unless defined $chars;
- $dir = $Vend::Cfg->{ScratchDir} unless $dir;
+
+ # Accomodate PermanentDir not existing in pre-5.3.1 catalogs
+ # Block is better than always doing -d test
+ if(! $dir) {
+ $dir = $Vend::Cfg->{ScratchDir};
+ }
+ else {
+ mkdir $dir, 0777 unless -d $dir;
+ }
+
for($i = 0; $i < $levels; $i++) {
$dir .= "/";
$dir .= substr($file, $i * $chars, $chars);
2.233 +11 -22 interchange/lib/Vend/Interpolate.pm
rev 2.233, prev_rev 2.232
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.232
retrieving revision 2.233
diff -u -r2.232 -r2.233
--- Interpolate.pm 1 Feb 2005 02:07:15 -0000 2.232
+++ Interpolate.pm 6 Mar 2005 04:14:08 -0000 2.233
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.232 2005/02/01 02:07:15 jon Exp $
+# $Id: Interpolate.pm,v 2.233 2005/03/06 04:14:08 mheins Exp $
#
# Copyright (C) 2002-2005 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.232 $, 10);
+$VERSION = substr(q$Revision: 2.233 $, 10);
@EXPORT = qw (
@@ -3048,6 +3048,7 @@
$opt,
$r,
$chunk,
+ $perm,
$total,
$current,
$page,
@@ -3093,7 +3094,7 @@
}
else {
$pa =~ s/__BORDER__/$border/e;
- $arg = "$session:$next:$last:$chunk";
+ $arg = "$session:$next:$last:$chunk$perm";
$list .= more_link_template($pa, $arg, $form_arg) . ' ';
}
return $list;
@@ -3122,6 +3123,7 @@
$session = $q->{mv_cache_key};
my $first = $q->{mv_first_match} || 0;
$chunk = $q->{mv_matchlimit};
+ $perm = $q->{mv_more_permanent} ? ':1' : '';
$total = $q->{matches};
my $next = defined $q->{mv_next_pointer}
? $q->{mv_next_pointer}
@@ -3181,7 +3183,7 @@
$arg = $session;
$arg .= ':0:';
$arg .= $chunk - 1;
- $arg .= ":$chunk";
+ $arg .= ":$chunk$perm";
$list .= more_link_template($first_anchor, $arg, $form_arg) . ' ';
}
@@ -3202,7 +3204,7 @@
$arg .= $first - $chunk;
$arg .= ':';
$arg .= $first - 1;
- $arg .= ":$chunk";
+ $arg .= ":$chunk$perm";
$list .= more_link_template($prev_anchor, $arg, $form_arg) . ' ';
}
@@ -3226,7 +3228,7 @@
}
$last = $next + $chunk - 1;
$last = $last > ($total - 1) ? $total - 1 : $last;
- $arg = "$session:$next:$last:$chunk";
+ $arg = "$session:$next:$last:$chunk$perm";
$next_tag .= more_link_template($next_anchor, $arg, $form_arg);
# Last link can appear when next link is valid
@@ -3239,7 +3241,7 @@
unless ($last_anchor eq 'none') {
$last = $total - 1;
my $last_beg_idx = $total - ($total % $chunk || $chunk);
- $arg = "$session:$last_beg_idx:$last:$chunk";
+ $arg = "$session:$last_beg_idx:$last:$chunk$perm";
$next_tag .= ' ' . more_link_template($last_anchor, $arg, $form_arg);
}
}
@@ -4494,11 +4496,9 @@
sub opt_region {
my $opt = pop @_;
-#::logDebug("opt_region called, prefix=$Prefix, text=$_[-1]");
my $new = { %$opt };
my $out = iterate_hash_list(@_,[$new]);
$Prefix = $Orig_prefix;
-#::logDebug("opt_region prefix=$Prefix, results=$out");
return $out;
}
@@ -4510,27 +4510,19 @@
if($opt->{object}) {
### The caller supplies the object, no search to be done
- #::logDebug("region: object was supplied by caller.");
$obj = $opt->{object};
}
else {
### We need to run a search to get an object
- #::logDebug("region: no object supplied");
my $c;
if($CGI::values{mv_more_matches} || $CGI::values{MM}) {
### It is a more function, we need to get the parameters
- #::logDebug("more object = $CGI::values{mv_more_matches}");
-
find_search_params();
delete $CGI::values{mv_more_matches};
-
-#::logDebug("more object = " . uneval($c));
-
}
elsif ($opt->{search}) {
### Explicit search in tag parameter, run just like any
- #::logDebug("opt->search object label=$opt->{label}.");
if($opt->{more} and $::Instance->{SearchObject}{''}) {
$obj = $::Instance->{SearchObject}{''};
#::logDebug("cached search");
@@ -4542,19 +4534,16 @@
my $params = escape_scan($opt->{search});
Vend::Scan::find_search_params($c, $params);
$c->{mv_no_more} = ! $opt->{more};
-#::logDebug("perform_search, c=" . ::uneval($c));
$obj = perform_search($c);
}
}
else {
### See if we have a search already done for this label
- #::logDebug("try labeled object label=$opt->{label}.");
$obj = $::Instance->{SearchObject}{$opt->{label}};
}
# If none of the above happen, we need to perform a search
# based on the passed CGI parameters
- #::logDebug("no found object") if ! $obj;
if(! $obj) {
$obj = perform_search();
$obj = {
@@ -4565,10 +4554,9 @@
finish_search($obj);
# Label it for future reference
- #::logDebug("labeling as '$opt->{label}'");
-
$::Instance->{SearchObject}{$opt->{label}} = $opt->{object} = $obj;
}
+
my $lprefix;
my $mprefix;
if(defined $opt->{list_prefix}) {
@@ -4591,6 +4579,7 @@
$obj->{mv_more_decade} = $opt->{md};
$obj->{matches} = scalar @{$obj->{mv_results}};
$obj->{mv_cache_key} = generate_key($opt->{query} || substr($page,0,100));
+ $obj->{mv_more_permanent} = $opt->{pm};
$obj->{mv_first_match} = $opt->{fm} if $opt->{fm};
$obj->{mv_search_page} = $opt->{sp} if $opt->{sp};
$obj->{prefix} = $opt->{prefix} if $opt->{prefix};
2.28 +13 -3 interchange/lib/Vend/Scan.pm
rev 2.28, prev_rev 2.27
Index: Scan.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Scan.pm,v
retrieving revision 2.27
retrieving revision 2.28
diff -u -r2.27 -r2.28
--- Scan.pm 20 Jul 2004 05:24:00 -0000 2.27
+++ Scan.pm 6 Mar 2005 04:14:08 -0000 2.28
@@ -1,6 +1,6 @@
# Vend::Scan - Prepare searches for Interchange
#
-# $Id: Scan.pm,v 2.27 2004/07/20 05:24:00 mheins Exp $
+# $Id: Scan.pm,v 2.28 2005/03/06 04:14:08 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.27 $, 10);
+$VERSION = substr(q$Revision: 2.28 $, 10);
use strict;
use Vend::Util;
@@ -165,6 +165,7 @@
op mv_column_op
os mv_orsearch
pf prefix
+ pm mv_more_permanent
ra mv_return_all
rd mv_return_delim
re mv_search_reference
@@ -263,6 +264,10 @@
push @out, "$RevScan{$key}=$_";
}
}
+
+ # Make repeatable for permanent store
+ @out = sort @out;
+
$Vend::Session->{last_search} = join "/", 'scan', @out;
}
@@ -411,12 +416,15 @@
my($c,$more_matches,$pre_made) = @_;
#::logDebug('searching....');
if (!$c) {
+#::logDebug("No search object");
return undef unless $Vend::Session->{search_params};
($c, $more_matches) = @{$Vend::Session->{search_params}};
unless($c->{mv_cache_key}) {
+#::logDebug("No cache key");
Vend::Scan::create_last_search($c);
$c->{mv_cache_key} = generate_key($Vend::Session->{last_search});
}
+#::logDebug("Found search object=" . ::uneval($c));
}
elsif ($c->{mv_search_immediate}) {
unless($c->{mv_cache_key}) {
@@ -436,11 +444,13 @@
my %options;
$options{mv_session_id} = $c->{mv_session_id} || $Vend::SessionID;
if($c->{mv_more_matches}) {
- @options{qw/mv_cache_key mv_next_pointer mv_last_pointer mv_matchlimit/}
+#::logDebug("Found search object=" . ::uneval($c));
+ @options{qw/mv_cache_key mv_next_pointer mv_last_pointer mv_matchlimit mv_more_permanent/}
= split /:/, $c->{mv_more_matches};
$options{mv_more_id} = $c->{mv_more_id}
if $c->{mv_more_id};
my $s = new Vend::Search %options;
+#::logDebug("resulting search object=" . ::uneval($s));
$q = $s->more_matches();
finish_search($q);
return $q;
2.27 +38 -8 interchange/lib/Vend/Search.pm
rev 2.27, prev_rev 2.26
Index: Search.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Search.pm,v
retrieving revision 2.26
retrieving revision 2.27
diff -u -r2.26 -r2.27
--- Search.pm 10 Sep 2004 23:17:57 -0000 2.26
+++ Search.pm 6 Mar 2005 04:14:08 -0000 2.27
@@ -1,6 +1,6 @@
# Vend::Search - Base class for search engines
#
-# $Id: Search.pm,v 2.26 2004/09/10 23:17:57 jon Exp $
+# $Id: Search.pm,v 2.27 2005/03/06 04:14:08 mheins Exp $
#
# Copyright (C) 2002-2004 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -22,7 +22,7 @@
package Vend::Search;
-$VERSION = substr(q$Revision: 2.26 $, 10);
+$VERSION = substr(q$Revision: 2.27 $, 10);
use strict;
use vars qw($VERSION);
@@ -347,8 +347,15 @@
my($s) = @_;
$s->{more_in_progress} = 1;
- my $id = $s->{mv_more_id} || $s->{mv_session_id};
- $id .= ".$s->{mv_cache_key}";
+ my $id;
+ if($s->{mv_more_permanent}) {
+#::logDebug("Permanent more");
+ $id = $s->{mv_cache_key};
+ }
+ else {
+ $id = $s->{mv_more_id} || $s->{mv_session_id};
+ $id .= ".$s->{mv_cache_key}";
+ }
my $file;
my $obj;
@@ -365,7 +372,13 @@
);
}
else {
- $file = Vend::Util::get_filename($id);
+ if($s->{mv_more_permanent}) {
+ $file = Vend::File::get_filename($id, 2, 1, $Vend::Cfg->{PermanentDir});
+ }
+ else {
+ $file = Vend::File::get_filename($id);
+ }
+
#::logDebug("more_matches: $id from $file");
eval {
$obj = Vend::Util::eval_file($file);
@@ -1163,8 +1176,19 @@
return if $MVSAFE::Safe;
my $file;
delete $s->{dbref} if defined $s->{dbref};
- my $id = $s->{mv_more_id} || $Vend::SessionID;
- $id .= ".$s->{mv_cache_key}";
+
+ my $id;
+ my $storedir;
+
+ unless($s->{mv_more_permanent}) {
+ $id = $s->{mv_more_id} || $Vend::SessionID;
+ $id .= ".$s->{mv_cache_key}";
+ }
+ else {
+ $id = $s->{mv_cache_key};
+ $storedir = $Vend::Cfg->{PermanentDir};
+ }
+
if ($s->{matches} > $s->{mv_matchlimit} and $s->{mv_matchlimit} > 0) {
$s->{overflow} = 1;
$s->{mv_next_pointer} = $s->{mv_matchlimit};
@@ -1193,7 +1217,13 @@
else {
#::logDebug("save_more: $id to $file.");
#::logDebug("save_more:object:" . ::uneval($new));
- $file = Vend::Util::get_filename($id);
+ if($storedir) {
+ $file = Vend::File::get_filename($id,2,1,$storedir);
+ }
+ else {
+ $file = Vend::File::get_filename($id);
+ }
+
eval {
Vend::Util::uneval_file($new, $file);
};
More information about the interchange-cvs
mailing list