logo       

Re: CAP-AnyTemplate & mod_perl: msg#00271

Subject: Re: CAP-AnyTemplate & mod_perl
> >> Trying to get CA plus some plugins working under mod_perl.
> >> CAP-AnyTemplate (v0.07) works fine as part of regular cgi script, but
> >> when run under mod_perl:
> >
> >> $self->template->config(
> >>     Configs->AT_CONFIG,
> >> );
> >
> >Do you put the call to $self->template->config inside of your
> >application's setup or cgiapp_init methods?  Or is it outside all
> >methods?
> >
> It is part of cgiapp_init(). Incidentally, AT_CONFIG is inside package
> Configs, which I did not make clear in my original message (though
> obvious I hope).

Hmmm.. your error messages indicate the HTML::Template driver is being
used, so it really does look like $self->template is not getting its
config data properly (and so it is falling back to the defaults).

Could you try something like the following and verify that
Configs->AT_CONFIG contains what you think it contains at init time?

    sub cgiapp_init {
        my $self = shift;

        # ... other init stuff goes here ...

        my $at_config = Configs->AT_CONFIG;
        
        use Data::Dumper;
        print STDERR Dumper $at_config;

        $self->template->config(
            $at_config
        );
    }

And then look at the error log.

I tried duplicating your setup here and it does seem to work for me. 
Here's what I did:

    #####################################
    # lib/Configs.pm

    use strict;
    package Configs;

    use constant TMPL_PATH => '/path/to/templates';
    use constant AT_CONFIG => { # hashref for use in AnyTemplate:
        type => 'TemplateToolkit',
        include_paths => [
          TMPL_PATH,
          TMPL_PATH . '/HILIS4',
        ],

        TemplateToolkit => {
          TAG_STYLE => 'asp', # <% ... %>
          INTERPOLATE => '1', # use $vars
        }
    };

    1;

    #####################################
    # lib/My/Webapp.pm

    use strict;
    use CGI::Carp qw/fatalsToBrowser/;
    package My::Webapp;
    use Configs;

    use base 'CGI::Application';
    use CGI::Application::Plugin::AnyTemplate;

    sub setup {
        my $self = shift;
        $self->run_modes([qw/login/]);
        $self->start_mode('login');
    }
    sub cgiapp_init {
        my $self = shift;

        $self->template->config(
            Configs->AT_CONFIG,
        );
    }
    sub login { 
        my $self = shift; 

        $self->template->fill();
    }

    1;

    #####################################
    # lib/My/Handler.pm

    package My::Handler;
    use strict;
    use My::Webapp;

    sub handler {
        my $r = shift;
        My::Webapp->new->run;
    }

    1;

    #####################################
    # /path/to/templates/HILIS4/login.html

    <html>
    <body>
    Please login!
    </body>
    </html>



    #####################################
    # httpd.conf
    <Perl>
        use lib '/path/to/lib';
    </Perl>

    <Location /test_app>
        SetHandler perl-script
        PerlHandler My::Handler
    </Location>


Note, that this is a bare mp2 handler, not Registry, so that might have
something to do with it...


Michael


--
Michael Graham <magog@xxxxxxxxxxxx>



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@xxxxxxxxxxxxxxxxx/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: cgiapp-unsubscribe@xxxxxxxxxxxxxxxxx
For additional commands, e-mail: cgiapp-help@xxxxxxxxxxxxxxxxx




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe