perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerald Richter" <rich...@ecos.de>
Subject RE: Embperl::Object::Execute help within PERL scripts for templating.
Date Fri, 06 Oct 2006 04:30:49 GMT
Hello,

If I understand right, you what to have Embperl::Object generate the base
template and include your old pages, which are written in pure Perl, into
it, like other Embperl pages, right?

In this case you should go the other way round. Instead of using
Apache::Registry you should call your Perl script in your base.epl, with the
Paramter syntax => 'Perl'. 

You could also overwrite the method get_receipe of the application object,
to automaticly set the syntax value (see eg/web/epwepapp.pl for an example)

Gerald


> 
> I'm running Embperl 2.2.0, mod_perl 2.0.2 under Apache 2.2.3. 
>  I have successfully setup Embperl 2 for templating my 
> website (templates display properly for .html files).  What I 
> am trying to do now is convert some PERL scripts I have to 
> make use of the Embperl templating features with only minor 
> modifications ($r->print to Embperl::Object::Execute...).
> 
> Here is a test script before conversion:
> 
> my $r = shift;
> subTest(\$r);
> sub subTest {
>         my $r = shift;
>         my ($content,$cgienvvar);
>         $content = "<HTML><BODY>";
>         $content .= "<H1> Test </H1>\n";
>         $content .= "</BODY></HTML>";
>         $$r->content_type("text/html");
>         $$r->print("$content");
>         return Apache2::Const::OK;
> } # end subTest
> 
> Result: Displays as expected.
> 
> Here is the same script after I converted to work with Embperl:
> 
> use Embperl;
> use Embperl::Object;
> my $r = shift;
> subTest(\$r);
> sub subTest {
>         my $r = shift;
>         my ($content,$cgienvvar);
>         $content = "<H1> Test </H1>\n";
>         Embperl::Object::Execute({
>                 input => \$content,
>                 mtime => 1,
>                 req_rec => $$r
>         });
> } # end subTest
> 
> Result: Displays the HTML properly but the Embperl template 
> is not used.
> 
> And here are the Apache conf pieces relevant for Embperl:
> 
>     AddType text/html .epl
>     EMBPERL_APPNAME testapp
>     EMBPERL_DEBUG 0x7fffffff
>     EMBPERL_ESCMODE 0
>     EMBPERL_OPTIONS 16
>     EMBPERL_OBJECT_BASE _base.epl
>     PerlModule Embperl
> 
>     <FilesMatch "\.htm.?|\.epl$">
>         SetHandler perl-script
>         PerlHandler Embperl::Object
>     </FilesMatch>
> 
>         ScriptAlias /cgi-bin/ /data/apache/htdocs/testsite/cgi-bin/
>         <Directory "/data/apache/htdocs/testsite/cgi-bin/">
>         <FilesMatch "\.pl$">
>                 EMBPERL_APPNAME test
>                 SetHandler perl-script
>                 PerlResponseHandler ModPerl::Registry
>         </FilesMatch>
>                 SSLRequireSSL
>                 SSLOptions +StdEnvVars
>                 AllowOverride None
>                 Options None +ExecCGI
>                 Order allow,deny
>                 Allow from all
>         </Directory>
> 
> When *.html files are processed I can see Embperl 
> (embperl.log) going through the _base.epl file then to each 
> of the other parts of the template.  When the *.pl script is 
> run the embperl.log file shows the new APPNAME 'test" and 
> only _base.epl being found and imported, I don't see 
> references to any other piece of the template and none of the 
> template is sent to the browser.  I've attempted many 
> variations on Embperl::Object::Execute including specifying 
> appname, object_base/object_addpath, and inputfile values.
> 
> Am I way off on how I am trying to use 
> Embperl::Object::Execute in this way?  For the purposes of 
> this exercise I want to avoid a complete conversion to 
> Embedded perl within .html files.
> 
> Thanks for the help,
> 
> Chris
> 
> 


 
** Virus checked by BB-5000 Mailfilter ** 


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message