Interchange, by default, uses an ImageDir for a prefix. In the demo,
image specs that have no absolute path information are prefixed with
/simple/images/.
In an Interchange page, this tag:
will become this:
This tag:
will become this:
Absolute image paths are not affected. An image such as
/other/images/whatever.gif will not be changed.
2. INSTALLATION
===============
2.1. Configuration Problems
---------------------------
Most Interchange configuration and setup problems are due to one of
the following:
Wrong information given to makecat program.
This is by far the most common problem. To install a working
demo, Interchange needs to know what the DocumentRoot is and how
to run CGI programs. Details of this setup are server- and
site-specific, which may require some research.
Re-run the configuration again, and pay close attention to the
prompts given. There are examples given which apply to most
systems.
If the web server is Apache or NCSA, 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.
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.
Perl compiled with USE_THREADS.
Run perl -V. If you see -DUSE_THREADS in the compilation
definition, you might run into problems with Interchange.
NOTE: You cannot run the Interchange software as root.
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:
-rwsr-xr-x 1 interchange users 6312 Dec 30 11:39 cgi-bin/simple
and for the socket file it should be:
srw------- 1 interchange users 0 Dec 30 11:41 etc/socket
Once you have set up the software, you can easily install catalogs as
root as long as your umask is set to 2 or 22.
(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).
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:
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
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:
This will make files default to the proper group when created (on most
UNIX versions, anyway).
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
If you are on a virtual hosting system, the procedure varies. Making
the program setuid should work for most systems. If your setup uses
CGI-WRAP 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 CGI setup, as some virtual host
systems do, you will need to know something about UNIX and the web or
engage a consultant to properly set up the paths. Usually switching to
TLINK/INET mode is the easiest thing to do, though with Iserver and a
few others it may take more than that.
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:
chmod u+s cgi-bin/simple
2.2. Error -- the Interchange server was not running...
-------------------------------------------------------
This indicates that the link CGI is not communicating with the
Interchange server. Important note: The server should always be
started by the same user ID which owns the suid vlink program. (This
does not apply to TLINK/INET mode.)
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:
bin/interchange -restart
You can check to see if your server is running by typing:
Linux, BSD: ps -ax | grep interchange
Most other systems: ps -elf | grep interchange
Note: Solaris and IRIX truncate the string, and don't allow setting of
the $0 parameter. You may have to grep for 'perl' instead.
If the server is not running, it may have failed due to another
process occupying the TCP socket 7786. If using VLINK, try starting
Interchange with start -u, which will not monitor the internet-domain
socket.
If VLINK is not communicating with the server, there are a number of
possible reasons. First, if you are trying to run Interchange on an
ISP, go to the section about ISP problems. It is probably one of
those. If you are running Interchange on a single machine, it is
probably one of:
1. Permissions problems
2. Interchange on NFS-mounted file system
Check the error_log file for your HTTP server -- it will almost always
tell you what the problem is, unless there is a simple permissions
problem.
Permissions are easy. If starting Interchange like this works:
interchange -r SocketPerms=666
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:
chmod u+s cgi-bin/storename
chmod u-s cgi-bin/storename
cgi-bin/storename = path to your executable
If neither of those work, either the UID the program is owned by is
wrong, or your HTTP 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 NFS. You will
need to change to static mode from server mode, or better yet, put
Interchange on a file system that is directly mounted.
You can use Interchange in INET mode along with the tlink.c program to
allow running across NFS boundaries. If you have not changed the
configured defaults, and still it will not communicate, you should try
setting the LINK_HOST and LINK_PORT directives in tlink.c and
recompiling.
2.3. 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 UNIX, try reinstalling
Interchange and using the standard Perl installation sequence:
/complete/path/to/proper/perl Makefile.PL
make
make test
make install
Otherwise, contact your system administrator.
2.4. Can't locate lib.pm in @INC. BEGIN failed--compilation 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.
2.5. 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).
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, ISP, or the Perl porters.
2.6. 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 ,
# and the DM
Locale de_DE
Locale de_DE p_cs_precedes 0
Locale de_DE p_sep_by_space 2
Note: Be sure to use the latest exchange rates when you establish your
catalog.
On your pages (this is from a search results page, the [item-.... ...]
notation may be different depending on your context):
[item-price]| Product | SK/b | Stock | @@ -120,6 +121,11 @@|
|
+ [if file images/thumb/[item-field thumb]]
+ |
+ [item-description] | 8.14. How do I do a random display of items? -------------------------------------------- (Answered by Bill Carr) If you are using mysql (and others probably), you should be able to add "ORDER BY RAND()" to your SQL query. For example: [query list=1 sql=|SELECT * FROM products ORDER BY RAND() LIMIT 3| ] [list] [sql-param description]||
| [loop-code] | [loop-alternate 3]
if scratch compare: [benchmark start=1] [benchmark]
if scratch compare eq 1: [benchmark start=1] [benchmark]
[page @@MV_PAGE@@]Again
---- end test ---
o Use [PREFIX-calc] instead of [calc] or [perl]
You can execute the same code as [calc] with [PREFIX-calc], which has
two benefits:
11. It doesn't require ITL parsing.
12. It is executed during the loop instead of after it.
The [PREFIX-calc] object has complete access to all normal embedded
Perl objects like $Values, $Carts, $Tag, and such. If you want to make
a data table (i.e. "products" or "pricing") available for access
inside of it, just do:
[perl tables="products pricing"] [/perl]
prior to list start. Now you can do something like:
[loop search="ra=yes"]
[loop-calc]
$desc = $Tag->data('products', 'description', '[loop-code]');
$link = $Tag->page('[loop-code]');
return "$link $desc ";
[/loop-calc]
[/loop]
o ADVANCED: Precompile and execute with [PREFIX-sub] and
[PREFIX-exec]
For repetitive routines, you can achieve a considerable savings in CPU
by pre-compiling your embedded Perl code.
In the "Construct Something" demo, the bar_link() routine in
catalog_before.cfg is an example of compiling the subroutine once at
catalog configuration time.
You can also compile routines at the time of the list execution with
[item-sub routine] CODE [/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.
Example:
[benchmark start=1]
loop-calc:
[benchmark]
[benchmark start=1]
loop-sub and loop-exec:
[benchmark]
o ADVANCED: Execute and save with [query ...], then use an embedded
Perl routine.
You can run [query arrayref=myref sql="query"], which saves the
results of the search/query in a Perl reference. It is then available
in $Tmp->{myref}. (Of course, "myref" can be any arbitrary name.)
This is the fastest possible method to display a list.
Observe:
--- begin test code ---
[set waiting_for]os28004[/set]
[benchmark start=1] Embedded Perl
[/query]
[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!!!!\n";
}
$out .= "sku: $sku price: $price description: $desc\n";
}
return $out;
[/perl]
-->
TIME: [benchmark]
[benchmark start=1] All loop
TIME: [benchmark]
--- end test code ---
o Other things that help:
o 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.
o 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.
o 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.
14. Using Interchange with Oracle
=================================
Question: should we be using the DBI ChopBlanks setting for Oracle or
is Interchange trimming trailing space from CHAR fields itself?
IC daemon user should have environment variables ORACLE_HOME and
possibly NLS_LANG set.
Mark Johnson (mark@endpoint.com) wrote this trigger on TABLE_NAME to
update the MOD_TIME column on insert or update. The user must have
been granted the RESOURCE role to create triggers. Here it is:
CREATE TRIGGER tr_modtime_for_TABLE_NAME BEFORE INSERT OR UPDATE ON
TABLE_NAME FOR EACH ROW BEGIN
new.MOD_TIME := SYSDATE; END; /
15. Using Interchange with PostgreSQL
=====================================
Make sure you have DBD::Pg installed and tested. Make sure
POSTGRES_INCLUDE and POSTGRES_LIB environment variables are set.
16. Using Interchange with MySQL
================================
Permissions. test_ databases usually special.
17. Using Interchange with Apache
=================================
Slightly modified article posted to the old minivend-users mail list.
Minivend-users is now interchange-users.
Date: Thu, 7 Sep 2000 12:08:37 -0700
From: Bill Randle