.Ve
will become this:
.PP
.Vb 1
\&
.Ve
This tag:
.PP
.Vb 1
\&
.Ve
will become this:
.PP
.Vb 1
\&
.Ve
Absolute image paths are not affected. An image such as
/other/images/whatever.gif will not be changed.
.SH "INSTALLATION"
.IX Header "INSTALLATION"
.Sh "Configuration Problems"
.IX Subsection "Configuration Problems"
Most Interchange configuration and setup problems are due to one of
the following:
.Ip "Wrong information given to makecat program." 4
.IX Item "Wrong information given to makecat program."
\&\fBThis is by far the most common problem.\fR To install a working demo,
Interchange needs to know what the DocumentRoot is and how to run
\&\s-1CGI\s0 programs. Details of this setup are server- and site-specific,
which may require some research.
.Sp
Re-run the configuration again, and pay close attention to the prompts
given. There are examples given which apply to most systems.
.Sp
If the web server is Apache or \s-1NCSA\s0, Interchange will try and parse
its httpd.conf file to help you along, but many ISPs don't allow
users to read these and it may fail.
.Ip "Too-low version of Perl." 4
.IX Item "Too-low version of Perl."
If you have a Perl earlier than 5.005, Interchange will not work.
Don't even try an earlier version.
.Ip "Perl compiled with \s-1USE_THREADS\s0." 4
.IX Item "Perl compiled with USE_THREADS."
Run perl \-V. If you see \-DUSE_THREADS in the compilation
definition, you might run into problems with Interchange.
.Sp
\&\fB\s-1NOTE\s0\fR: You cannot run the Interchange software as root.
.PP
If you are setting Interchange up for the entire machine, and not just
as a virtual host user, it is usual to create a special interch
user to run the daemon and the link program. This means the directory
listing for your cgi-bin should be something like:
.PP
.Vb 1
\& -rwsr-xr-x 1 interchange users 6312 Dec 30 11:39 cgi-bin/simple
.Ve
and for the socket file it should be:
.PP
.Vb 1
\& srw------- 1 interchange users 0 Dec 30 11:41 etc/socket
.Ve
Once you have set up the software, you can easily install catalogs as
root \fBas long as your umask is set to 2 or 22\fR.
.PP
(The following assumes you have made the Interchange software owned
and run by the special user interchange and that each user has a
Interchange catalogs directory /home/user/catalogs).
.PP
The best way to set permissions on a multi-user system is to make all
files group readable and writable (660 or 664 mode). If you have a
system setup that places each user in their own group, make
interchange a member of each user's group and set ownership and
permissions with:
.PP
.Vb 3
\& find /home/user/catalogs -print | xargs chown user
\& find /home/user/catalogs -print | xargs chgrp user
\& find /home/user/catalogs -print | xargs chmod g+rw
.Ve
For best results, set the user's default umask to 2, so that they
will, by default, create files that have the proper permissions. If
you have all users in the same group, the above is not secure. You
should put interchange in a group of which no user is a member
(perhaps interchange would be a good choice) and set all files owned
by the group interchange and all directories to mode 2770:
.PP
This will make files default to the proper group when created (on most
\&\s-1UNIX\s0 versions, anyway).
.PP
.Vb 4
\& find /home/user/catalogs -print | xargs chown user
\& find /home/user/catalogs -print | xargs chgrp interchange
\& find /home/user/catalogs -print | xargs chmod g+rw
\& find /home/user/catalogs -type d -print | xargs chmod g+s
.Ve
If you are on a virtual hosting system, the procedure varies. Making
the program setuid should work for most systems. If your setup uses
\&\s-1CGI-WRAP\s0 or another setuid scheme, it should still work. However, you
may have to unset the setuid bit with chmod u-s cgi-bin/simple or
the like. If you have a non-standard \s-1CGI\s0 setup, as some virtual host
systems do, you will need to know something about \s-1UNIX\s0 and the web or
engage a consultant to properly set up the paths. Usually switching to
\&\s-1TLINK/INET\s0 mode is the easiest thing to do, though with Iserver and a
few others it may take more than that.
.PP
If you used the makecat program to build the catalog, it should
have warned you if it was not able to make the link program setuid. To
set the program (in the file cgi-bin/simple in this example) to be
setuid, use the command:
.PP
.Vb 1
\& chmod u+s cgi-bin/simple
.Ve
.Sh "Error \*(-- the Interchange server was not running..."
.IX Subsection "Error the Interchange server was not running..."
This indicates that the link \s-1CGI\s0 is not communicating with the
Interchange server. \fBImportant note:\fR The server should always be
started by the same user \s-1ID\s0 which owns the suid vlink program. (This
does not apply to \s-1TLINK/INET\s0 mode.)
.PP
The server must be running, first of all. If you didn't start it, you
can do so by going to the Interchange home directory and typing:
.PP
.Vb 1
\& bin/interchange -restart
.Ve
You can check to see if your server is running by typing:
.PP
.Vb 2
\& Linux, BSD: ps -ax | grep interchange
\& Most other systems: ps -elf | grep interchange
.Ve
\&\fBNote: \fRSolaris and \s-1IRIX\s0 truncate the string, and don't allow setting
of the \f(CW$0\fR parameter. You may have to grep for 'perl' instead.
.PP
If the server is not running, it may have failed due to another
process occupying the \s-1TCP\s0 socket 7786. If using \s-1VLINK\s0, try starting
Interchange with start \-u, which will not monitor the
internet-domain socket.
.PP
If \s-1VLINK\s0 is not communicating with the server, there are a number of
possible reasons. First, if you are trying to run Interchange on an
\&\s-1ISP\s0, go to the section about \s-1ISP\s0 problems. It is probably one of
those. If you are running Interchange on a single machine, it is
probably one of:
.PP
.Vb 2
\& 1. Permissions problems
\& 2. Interchange on NFS-mounted file system
.Ve
Check the error_log file for your \s-1HTTP\s0 server \*(-- it will almost always
tell you what the problem is, unless there is a simple permissions
problem.
.PP
Permissions are easy. If starting Interchange like this works:
.PP
.Vb 1
\& interchange -r SocketPerms=666
.Ve
then you have a socket permission problem. Try restarting interchange
without the above adjustment of SocketPerms=666, and then try
accessing it again with each of these mode changes:
.PP
.Vb 2
\& chmod u+s cgi-bin/storename
\& chmod u-s cgi-bin/storename
.Ve
.Vb 1
\& cgi-bin/storename = path to your executable
.Ve
If neither of those work, either the \s-1UID\s0 the program is owned by is
wrong, or your \s-1HTTP\s0 server is interfering in some fashion. If you are
running Interchange on an NFS-mounted file system, it cannot run in
server mode because UNIX-domain sockets don't work on \s-1NFS\s0. You will
need to change to static mode from server mode, or better yet, put
Interchange on a file system that is directly mounted.
.PP
You can use Interchange in \s-1INET\s0 mode along with the tlink.c program to
allow running across \s-1NFS\s0 boundaries. If you have not changed the
configured defaults, and still it will not communicate, you should try
setting the \s-1LINK_HOST\s0 and \s-1LINK_PORT\s0 directives in tlink.c and
recompiling.
.Sh "I get messages like 'Config.pm not found.' What does it mean?"
.IX Subsection "I get messages like 'Config.pm not found.' What does it mean?"
This means your Perl is not properly installed, or that Interchange is
not using the proper Perl binary. On \s-1UNIX\s0, try reinstalling
Interchange and using the standard Perl installation sequence:
.PP
.Vb 4
\& /complete/path/to/proper/perl Makefile.PL
\& make
\& make test
\& make install
.Ve
Otherwise, contact your system administrator.
.Sh "Can't locate lib.pm in \f(CW@INC\fP. \s-1BEGIN\s0 failed\*(--compilation aborted."
.IX Subsection "Can't locate lib.pm in @INC. BEGIN failedcompilation aborted."
Again, your Perl is not properly installed. Someone has put a Perl up
on your system, then either moved or removed the library directory.
Contact your system administrator and request that Perl be
re-installed.
.Sh "Segmentation fault or other core dump."
.IX Subsection "Segmentation fault or other core dump."
If this happens when you run the Interchange test or server, it is
always Perl that has a problem. Not sometimes, always. A proper Perl
should never have a segmentation violation, period. And it should not
dump core (unless you passed it a \-u option somehow).
.PP
You will need to either update Perl or report the bug to the proper
personnel. Depending on your situation and technical ability, this may
be your system admin, \s-1ISP\s0, or the Perl porters.
.Sh "Configuring catalog whatever...Use of uninitialized value at Config.pm line 1614, <\s-1CONFIG\s0> chunk 322."
.IX Subsection "Configuring catalog whatever...Use of uninitialized value at Config.pm line 1614,
"
\&Locale eur_EUR p_sep_by_space 2
\&Locale eur_EUR mon_decimal_point ,
.Ve
# and the \s-1DM\s0
Locale de_DE
Locale de_DE p_cs_precedes 0
Locale de_DE p_sep_by_space 2
.PP
\&\fBNote: \fRBe sure to use the latest exchange rates when you establish
your catalog.
.PP
On your pages (this is from a search results page, the [item-.... ...]
notation may be different depending on your context):
.PP
.Vb 4
\& [item-price]| \& | Product | \&SK/b | \&Stock | \&@@ -120,6 +121,11 @@ .Ve .Vb 10 \&
|
\&+ [if file images/thumb/[item-field thumb]]
\&+ |
\&+ \& \& [item-description] \& | .Ve .Sh "How do I do a random display of items?" .IX Subsection "How do I do a random display of items?" (Answered by Bill Carr) .PP If you are using mysql (and others probably), you should be able to add \*(L"\s-1ORDER\s0 \s-1BY\s0 \fIRAND()\fR\*(R" to your \s-1SQL\s0 query. For example: .PP .Vb 8 \& [query \& list=1 \& sql=|SELECT * FROM products ORDER BY RAND() LIMIT 3| \&] \&[list] \& [sql-param description]||
| [loop-code] | \& [loop-alternate 3]
.Ve .Vb 12 \& if scratch compare: \& [benchmark start=1] \& .Ve .Vb 2 \& [benchmark] \&
.Ve .Vb 14 \& if scratch compare eq 1: \& [benchmark start=1] \& \& [benchmark] \&
.Ve
.Vb 1
\& [page @@MV_PAGE@@]Again
.Ve
.Vb 1
\& ---- end test ---
.Ve
.Ip "\(bu" 4
Use [PREFIX-calc] instead of [calc] or [perl]
.PP
You can execute the same code as [calc] with [PREFIX-calc], which has
two benefits:
.Ip "11." 4
.IX Item "11."
It doesn't require \s-1ITL\s0 parsing.
.Ip "12." 4
.IX Item "12."
It is executed during the loop instead of after it.
.PP
The [PREFIX-calc] object has complete access to all normal embedded
Perl objects like \f(CW$Values\fR, \f(CW$Carts\fR, \f(CW$Tag\fR, and such. If you want to make
a data table (i.e. \*(L"products\*(R" or \*(L"pricing\*(R") available for access
inside of it, just do:
.PP
.Vb 1
\& [perl tables="products pricing"] [/perl]
.Ve
prior to list start. Now you can do something like:
.PP
.Vb 7
\& [loop search="ra=yes"]
\& [loop-calc]
\& $desc = $Tag->data('products', 'description', '[loop-code]');
\& $link = $Tag->page('[loop-code]');
\& return "$link $desc ";
\& [/loop-calc]
\& [/loop]
.Ve
.Ip "\(bu" 4
\&\s-1ADVANCED:\s0 Precompile and execute with [PREFIX-sub] and [PREFIX-exec]
.PP
For repetitive routines, you can achieve a considerable savings in \s-1CPU\s0
by pre-compiling your embedded Perl code.
.PP
In the \*(L"Construct Something\*(R" demo, the \fIbar_link()\fR routine in
catalog_before.cfg is an example of compiling the subroutine once at
catalog configuration time.
.PP
You can also compile routines at the time of the list execution with
[item-sub routine] \s-1CODE\s0 [/item-sub]. This means only one Safe
evaluation is done \*(-- every time the [loop-exec routine] is called, it
is done fast as a call to the routine. This can be 10 times or more
faster than separate [calc] calls, or 5 times faster than separate
[PREFIX-calc] calls.
.Ip "" 4
Example:
.Sp
.Vb 1
\& [benchmark start=1]
.Ve
.PP
.Vb 1
\& [benchmark]
.Ve
.Vb 1
\&
.Ve
.Vb 11
\& [benchmark start=1]
\& loop-sub and loop-exec:
\&
.Ve
.Vb 1
\& [benchmark]
.Ve
.Ip "\(bu" 4
\&\s-1ADVANCED:\s0 Execute and save with [query ...], then use an embedded Perl
routine.
.PP
You can run [query arrayref=myref sql=\*(L"query\*(R"], which saves the
results of the search/query in a Perl reference. It is then available
in \f(CW$Tmp\fR->{myref}. (Of course, \*(L"myref\*(R" can be any arbitrary name.)
.PP
This is the fastest possible method to display a list.
.Ip "" 4
Observe:
.Sp
.Vb 1
\& --- begin test code ---
.Ve
.PP
.Vb 5
\& [benchmark start=1] Embedded Perl
\&
\& [/query]
.Ve
.Vb 15
\& [perl]
\& # Get the query results, has multiple fields
\& my $ary = $Tmp->{myref};
\& my $out = '';
\& foreach $line (@$ary) {
\& my ($sku, $price, $desc) = @$line;
\& if($sku eq $Scratch->{waiting_for}) {
\& $out .= "We were waiting for this one!!!!\en";
\& }
\& $out .= "sku: $sku price: $price description: $desc\en";
\& }
\& return $out;
\& [/perl]
\& -->
\& TIME: [benchmark]
.Ve
.Vb 11
\& [benchmark start=1] All loop
\&
.Ve
.Vb 1
\& TIME: [benchmark]
.Ve
.Vb 1
\& --- end test code ---
.Ve
.Ip "\(bu" 4
Other things that help:
.RS 4
.Ip "\(bu" 8
Avoid interpolate=1 when possible. A separate tag parser must be
spawned every time you do this. Many times people use this without
needing it.
.Ip "\(bu" 8
Avoid saving large values to Scratch, as these have to be written to
the users session. If you need them only for the current page, clear
at the end by using [tmp scratch_var] contents [/tmp], which is the
same as [seti scratch_var] contents [/seti] except clears the value
before the session is written. You can also use [scratchd scratch_var]
to return the contents and delete them from the session at the same
time.
.Ip "\(bu" 8
Use the [more-list] facility to break up your large searches. You can
use them in [query ....] and [loop ...] searches as well \*(-- see the
docs.
.RE
.RS 4
.RE
.SH "Using Interchange with Oracle"
.IX Header "Using Interchange with Oracle"
Question: should we be using the \s-1DBI\s0 ChopBlanks setting for Oracle or
is Interchange trimming trailing space from \s-1CHAR\s0 fields itself?
.PP
\&\s-1IC\s0 daemon user should have environment variables \s-1ORACLE_HOME\s0 and
possibly \s-1NLS_LANG\s0 set.
.PP
Mark Johnson (mark@endpoint.com) wrote this trigger on \s-1TABLE_NAME\s0 to
update the \s-1MOD_TIME\s0 column on insert or update. The user must have
been granted the \s-1RESOURCE\s0 role to create triggers. Here it is:
.PP
\&\s-1CREATE\s0 \s-1TRIGGER\s0 tr_modtime_for_TABLE_NAME \s-1BEFORE\s0 \s-1INSERT\s0 \s-1OR\s0 \s-1UPDATE\s0 \s-1ON\s0
\&\s-1TABLE_NAME\s0 \s-1FOR\s0 \s-1EACH\s0 \s-1ROW\s0 \s-1BEGIN\s0
.PP
new.MOD_TIME := \s-1SYSDATE\s0; \s-1END\s0; /
.SH "Using Interchange with PostgreSQL"
.IX Header "Using Interchange with PostgreSQL"
Make sure you have \s-1DBD:\s0:Pg installed and tested. Make sure
\&\s-1POSTGRES_INCLUDE\s0 and \s-1POSTGRES_LIB\s0 environment variables are set.
.SH "Using Interchange with MySQL"
.IX Header "Using Interchange with MySQL"
Permissions. test_ databases usually special.
.SH "Using Interchange with Apache"
.IX Header "Using Interchange with Apache"
Slightly modified article posted to the old minivend-users mail list.
Minivend-users is now interchange-users.
.PP
.Vb 4
\& Date: Thu, 7 Sep 2000 12:08:37 -0700
\&From: Bill Randle