Name

Preload — specify macro to be executed at the very beginning of every request

SYNOPSIS

macro

DESCRIPTION

This is just like Autoload as it executes an Interchange macro but runs at the earliest possible stage of request processing, which allows tweaking the session, path, robot status, cookie handling, authorization, etc.

DIRECTIVE TYPE AND DEFAULT VALUE

Catalog directive

EXAMPLES

Example: Simple Preload example

This example shows how to not create a session for any but explicitly listed URL prefixes.

Put the following in interchange.cfg:

GlobalSub <<EOR
sub skip_session {
    $CGI::values{mv_tmp_session} = 1
        if $CGI::path_info =~ m{\A/(?:aboutus|contact|info)};
    return;
}
EOR

Put the following in catalog.cfg:

Preload skip_session

For diagnostic purposes, you can put a footer in your bottom page template to show the current session ID:

session ID=[data session id]

Restart Interchange, then visit various pages. Whenever you visit a page whose path starts with "aboutus", "contact", or "info", no session will be assigned, which you can verify by looking at your diagnostic output at the bottom of the page. This can be useful if you require cookies for session access, and don't want to incur the overhead of session access on pages that don't need it.


NOTES

AVAILABILITY

Preload is available in Interchange versions:

4.6.0-5.7.0 (git-head)

SOURCE

Interchange 5.7.0:

Source: lib/Vend/Config.pm
Line 591

['Preload',          'routine_array',    ''],

Source: lib/Vend/Config.pm
Line 3785 (context shows lines 3785-3819)

sub parse_routine_array {
my($item,$settings) = @_;

return '' unless $settings;

my $c;
if(defined $C) {
  $c = $C->{$item};
}
else {
  no strict 'refs';
  $c = ${"Global::$item"};
}

my @mac;

if($settings =~ /^[-\s\w,]+$/) {
  @mac = grep /\S/, split /[\s,]+/, $settings;
}
else {
  push @mac, $settings;
}

if(ref($c) eq 'ARRAY') {
  push @$c, @mac;
}
elsif($c) {
  $c = [$c, @mac];
}
else {
  $c = scalar(@mac) > 1 ? [ @mac ] : $mac[0];
}

return $c;
}

AUTHORS

Interchange Development Group

SEE ALSO

AutoEnd(7ic), Autoload(7ic)

DocBook! Interchange!