[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] 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 <suppressed>



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


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.