Hello, this is my first time posting to this list, so if I make any Snanfu's
please let me know. :-)

I am trying to subclass the provider.pm, like andy says, in order to use a
database. Everything appears to be working fine as long as you call the
program from the command line, but if I try and display it in a web browser,
it displays a blank page.

The server is Linux/Apache/Mod_Perl/Mysql-3.23, Web browser is Windows NT
WRKS/IE5.5.

Provider.PM
-----------
# C21RCenter Template::Provider
# Redefines Template::Provider->fetch() to allow an [%INCULDE%] to pull from
the database
# Thanks go to the Slashcode guys (http://slashcode.com) for a lot of the
ideas in this module.

package C21RCenter::Provider;
use base qw(Template::Provider);
use vars qw($VERSION);
use strict;

use constant PREV => 0;
use constant NAME => 1;
use constant DATA => 2; 
use constant LOAD => 3;
use constant NEXT => 4;

$VERSION = '0.1';

sub fetch {
        my ($self, $name) = @_;
        my ($data, $error, @Template, $text, $slot, $compfile, $size);
        $size = $self->{ SIZE };        

        @Template = &C21RCenter::DB::getTemplate($name);
        $name = $Template[0]; # Name of template in DB
        $text = $Template[1]; # Text of template in DB
                
        $compfile = $name . ".ttc";
                
        # cached entry exists, so refresh slot and extract data
        if ($name && ($slot = $self->{ LOOKUP }{ $name })) {
                ($data, $error) = $self->_refresh($slot);
                $data = $slot->[ DATA ] unless $error;

        # nothing in cache so try to load, compile and cache
        } else {
                ($data, $error) = $self->_load($name, $text);
                ($data, $error) = $self->_compile($data, $compfile) unless
$error;
                $data = $self->_store($name, $data) unless $error;
        }
    return ($data, $error);
}


sub _load {
        my($self, $name, $text) = @_;
        my($data, $error, $now, $time);
        $now = time;
        $time = 0;

        $data = {
                name    => $name,
                text    => $text,
                'time'  => $time,
                load    => $now,
        };

        return($data, $error);
}

1;

Thanks for any help you might be able to offer, and if you need more of my
code, just ask :-).

Chris Pickett
[EMAIL PROTECTED]


Reply via email to