|
From: barry <sla...@i1...> - 2001-10-16 03:04:41
|
I am trying to hook up a banner ad system that normally works vi SSI. I
have it set up and installed just fine w/ .shtml files, but I am not having
luck getting it to work in templates.
I tried to modify the templates with various combinations of code that
looks like this (the intent is to make an actually http request to the url
that will serve the ad - the url works directly from the browser)
[%
USE ua=LWP.UserAgent;
USE req=HTTP.Request;
%]
[% FOREACH extension = [ "_1a", "_1b"] %]
<td align=left>
[%
req.method("GET");
req.uri("$base_url$extension"); # this resolves to a valid url
ua.request(req).content;
%]
</td>
[% END %]
I set LOAD_PERL =1 in Template::Config, and added PerlModule LWP::UserAgent
and PerlModule HTTP::Request to the apache directives. I have done the
usual restart http routine, and have disabled slashd for now so that
index.pl doesn't run w/o my wanting it to.
Here is the problem - every third or so time I reload the page, I get this
error in the slash log file:
----------------------
no such context method/member: clone
[Tue Oct 16 03:13:02 2001] [error]
/index.pl:Apache::ROOTvslash::index_2epl:/usr/local/slash/site/slash/htdocs/index.pl:46:ID
53, index;index;default : plugin error - Can't locate object method "error"
via package "LWP::UserAgent" at
/usr/lib/perl5/site_perl/5.6.0/Template/Plugins.pm line 108.
[Tue Oct 16 03:13:02 2001] [error] Which was called
by:Apache::ROOTvslash::index_2epl:/usr/local/slash/site/slash/htdocs/index.pl:276:ID
53, index;index;default : plugin error - Can't locate object method "error"
via package "LWP::UserAgent" at
/usr/lib/perl5/site_perl/5.6.0/Template/Plugins.pm line 108.
---------------
After that, sometimes the page loads ok, sometimes it doesn't.
It looks to me like I could use a destructor call to the 2 objects at the
end of the template, but I tried that and it doesn't work either.
Is there a way to fix this code, or another way to either do a SSI from
inside a template, or access a URL somehow - I don't really care right now
which way I access the ads, just that I do....
Thanks!
Barry
|
|
From: Alessio B. <al...@al...> - 2001-10-16 06:35:01
|
barry wrote: > I am trying to hook up a banner ad system that normally works vi SSI. The only clean way I know is to print out your SSI commands as usual (<!--#include--> and the like) and then feed the output to SSIChain a in a OutputChain that will post-process it. This has to be configured in Apache - see the documentation for Apache::SSIChain http://search.cpan.org/doc/JANPAZ/Apache-OutputChain-0.07/SSIChain.pm > I tried to modify the templates with various combinations of code that > looks like this (the intent is to make an actually http request to the url > that will serve the ad - the url works directly from the browser) > > [% > USE ua=LWP.UserAgent; > USE req=HTTP.Request; > %] IMHO you are trying to make a big mess of it. -- Alessio F. Bragadini al...@al... APL Financial Services http://village.albourne.com Nicosia, Cyprus phone: +357-2-755750 "It is more complicated than you think" -- The Eighth Networking Truth from RFC 1925 |
|
From: Barry C. <bc...@i1...> - 2001-10-16 22:20:18
|
At 09:34 AM 10/16/2001 +0300, Alessio Bragadini wrote:
Alessio,
I got most of what you suggested implemented with a minimum of fuss and
bother, but I am still running into a gotcha....I can't find an answer to
this in any documentation on the web...what happens when the url the SSI
points to is virtual, and is handled by a Perl Handler itself?
Now I have the following (relavant) directives in my httpd.conf:
<Directory /usr/local/slash/site/slash/htdocs>
Options FollowSymLinks ExecCGI Includes Indexes
AllowOverride None
Order allow,deny
Allow from all
AddHandler perl-script .pl
PerlHandler Apache::OutputChain Apache::SSIChain Apache::Registry
</Directory>
# begin set up for the DAD ad server
<Location /dad>
SetHandler perl-script
PerlHandler DAD::public
</Location>
The ssi line I am trying to create in the slash template is something like
this:
<!--#include virtual="dad/ad?group=[%"$this_section$extension"%]" -->
SSI seems to work fine from regular .shtml files, and I can access the ad
server directly via URL so I am confident about most of the set up....
The down side is this: When I load a page, I get
[Tue Oct 16 22:19:18 2001] [error] Can't locate object method
"content_type" via package "DAD::public" at
/usr/lib/perl5/site_perl/5.6.0/DAD/public.pm line 57.
in my server error log file.
The code referenced in the error message is:
--------------------------
sub handler {
my ($r) = @_;
my $content;
$r->content_type('text/html'); # <----line 57
--------------------------
I tried a number of variations:
1 - <!--#exec cgi="dad/ad?group=[%"$this_section$extension"%]" --> gives
the same error
2- I dropped the ad server into the perl handler chain in all possible
positions to no avail
Any more suggestions?
Thanks a ton!
Barry
>barry wrote:
>
> > I am trying to hook up a banner ad system that normally works vi SSI.
>
>The only clean way I know is to print out your SSI commands as usual
>(<!--#include--> and the like) and then feed the output to SSIChain a in
>a OutputChain that will post-process it. This has to be configured in
>Apache - see the documentation for Apache::SSIChain
>
>http://search.cpan.org/doc/JANPAZ/Apache-OutputChain-0.07/SSIChain.pm
>
> > I tried to modify the templates with various combinations of code that
> > looks like this (the intent is to make an actually http request to the url
> > that will serve the ad - the url works directly from the browser)
> >
> > [%
> > USE ua=LWP.UserAgent;
> > USE req=HTTP.Request;
> > %]
>
>IMHO you are trying to make a big mess of it.
>
>--
>Alessio F. Bragadini al...@al...
>APL Financial Services http://village.albourne.com
>Nicosia, Cyprus phone: +357-2-755750
>
>"It is more complicated than you think"
> -- The Eighth Networking Truth from RFC 1925
>
>_______________________________________________
>Slashcode-general mailing list
>Sla...@li...
>https://lists.sourceforge.net/lists/listinfo/slashcode-general
|