Hi,
I am stuck with a little problem. I wanted to load some values with a Plugin at the beginnig of every call.
So I use a POST Plugin hook with init. As far as I can see $DB is defined in Links.pm -> sub init
# --------------------------------------------------------------------
# This function initializes Gossamer Links, and must be called before any other
# action is performed.
#
my $path = shift || '.';
# If under mod_perl, reset our environments.
if (PERSIST) {
GT::SQL->reset_env if $INC{'GT/SQL.pm'};
GT::CGI->reset_env();
}
# Get our config object.
$CFG = Links::Config->new($path);
my $debug = $CFG->{debug_level} || $DEBUG;
# Set our tmp directory to store files.
$ENV{GT_TMPDIR} = $CFG->{admin_root_path} . '/tmp';
$IN = GT::CGI->new();
$PLG = GT::Plugins->new(directory => "$CFG->{admin_root_path}/Plugins", debug => $debug);
if ($DB and not ref $DB eq 'GT::Delay') { # $DB is already a GT::SQL object
$DB = GT::SQL->new({
def_path => $CFG->{admin_root_path} . '/defs',
cache => 1,
debug => $debug
});
}
else {
$DB = GT::Delay(
'GT::SQL', 'HASH',
{
def_path => $CFG->{admin_root_path} . '/defs',
cache => 1,
debug => $debug
}
);
}
(%STASH, $GLOBALS, $LANGUAGE, $USER) = ();
$PLG->dispatch('init', sub {});
}
The last two lines were switched to make %STASH available.
I have some code to check for the $DB value in my Plugin script:
my (@args) = @_;
use Data::Dumper;
print $IN->header();
print Dumper($DB);
$DB is empty:
It would be nice to get some thoughts on how to approach this issue.
Thanks
n||i||k||o
I am stuck with a little problem. I wanted to load some values with a Plugin at the beginnig of every call.
So I use a POST Plugin hook with init. As far as I can see $DB is defined in Links.pm -> sub init
Code:
sub init { # --------------------------------------------------------------------
# This function initializes Gossamer Links, and must be called before any other
# action is performed.
#
my $path = shift || '.';
# If under mod_perl, reset our environments.
if (PERSIST) {
GT::SQL->reset_env if $INC{'GT/SQL.pm'};
GT::CGI->reset_env();
}
# Get our config object.
$CFG = Links::Config->new($path);
my $debug = $CFG->{debug_level} || $DEBUG;
# Set our tmp directory to store files.
$ENV{GT_TMPDIR} = $CFG->{admin_root_path} . '/tmp';
$IN = GT::CGI->new();
$PLG = GT::Plugins->new(directory => "$CFG->{admin_root_path}/Plugins", debug => $debug);
if ($DB and not ref $DB eq 'GT::Delay') { # $DB is already a GT::SQL object
$DB = GT::SQL->new({
def_path => $CFG->{admin_root_path} . '/defs',
cache => 1,
debug => $debug
});
}
else {
$DB = GT::Delay(
'GT::SQL', 'HASH',
{
def_path => $CFG->{admin_root_path} . '/defs',
cache => 1,
debug => $debug
}
);
}
(%STASH, $GLOBALS, $LANGUAGE, $USER) = ();
$PLG->dispatch('init', sub {});
}
The last two lines were switched to make %STASH available.
I have some code to check for the $DB value in my Plugin script:
Code:
sub init { my (@args) = @_;
use Data::Dumper;
print $IN->header();
print Dumper($DB);
$DB is empty:
Code:
$VAR1 = bless( {}, 'GT::Delay' );It would be nice to get some thoughts on how to approach this issue.
Thanks
n||i||k||o