You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Robert <ro...@robert.cz> on 2001/01/08 13:59:50 UTC
PerlTransHandler & EmbperlObject problem
I'm using custom PerlTransHandler and while with Embperl it worked OK,
with EmbperlObject it does funny things. When I comment PerlTransHandler
out, it works again, but in my test case the handler just returns
DECLINED. The exact problem is this: after server restart, first time I
load the URL I get the right result and embperl log has the usual stuff.
Then after first reload it just say 'File not found', nothing is written
to the embperl log and apache error log says 'file not found'. Does
anybody have any idea what went wrong? Thanks.
- Robert
url
===
http://nbczsecure/hotel-2/index.html
config
======
<VirtualHost nbczsecure>
ServerAdmin germic
DocumentRoot
/mnt/web/projekty/netbooking/current/nbczsecure/doc
ServerName nbczsecure
ErrorLog logs/nbczsecure.error_log
CustomLog logs/nbczsecure.access_log combined
# PerlSetEnv EMBPERL_DEBUG 10477
PerlTransHandler NetBooking::StripHotelName
<FilesMatch ".*\.html$">
PerlSetEnv EMBPERL_OBJECT_BASE base.html
PerlSetEnv EMBPERL_OBJECT_FALLBACK index.html
# PerlSetEnv EMBPERL_FILESMATCH "\.html$|\.epl$"
SetHandler perl-script
PerlHandler HTML::EmbperlObject
Options ExecCGI
</FilesMatch>
</VirtualHost>
error log
=========
[Mon Jan 8 15:01:57 2001] [error] EmbperlObject searched
';/mnt/web/projekty/netbooking/current/nbczsecure/doc/hotel-2;/mnt/web/projekty/netbooking/current/nbczsecure/doc'
/base.html
==========
[-
sub new {
my $self = shift;
$self->{dbh} = $req_rec->pnotes('DBH') || 'no dbh';
$self->{hotel_id} = $req_rec->pnotes('HOTEL_ID') || 'no
hid';
$self->{short_name} = $req_rec->pnotes('SHORT_NAME') ||
'no name';
}
# ... tvuj stuff
-]
<body>
[- Execute '*' -]
<hr>
dbh = [+ $r->{dbh} +]<br>
hotel_id = [+ $r->{$hotel_id} +]<br>
short_name = [+ $r->{short_name} +]<br>
</body>
/hotel-2/index.html
===================
[-
$r = shift;
$r->new;
-]
<h1 style='color: red'>Booking form for hotel *[+ $r->{short_name}
+]*</h1>
handler
=======
package NetBooking::StripHotelName;
use strict;
use Apache::Constants qw/:common BAD_REQUEST/;
use Apache::Log();
use DBI;
sub handler {
my $r = shift;
# Don't connect if it's just a picture or styleshit
return DECLINED if $r->uri =~ /\.gif$/ or $r->uri =~ /\.jpg$/ or
$r->uri =~ /\.css$/;
my ($junk, $short_name, @rest) = split '/', $r->uri;
# Fetch the hotel id from the database
#my $dbh = DBI->connect('DBI:Pg:dbname=nbcz', '', '', {
RaiseError =>
1, AutoCommit => 1 });
#my ($hotel_id, $short_name, $custom_page) =
$dbh->selectrow_array(
# "SELECT id,short_name,custom_page FROM hotel WHERE
short_name = ?",
{}, $short_name);
my ($dbh, $hotel_id, $short_name, $custom_page) = (undef, 1,
'hotel-1',
1);
#$r->log->error("DEBUG: hotel_id=$hotel_id,
short_name=$short_name,
custom_page=$custom_page ", $r->the_request);
$r->pnotes('DBH' => $dbh);
$r->pnotes('HOTEL_ID' => $hotel_id);
$r->pnotes('SHORT_NAME' => $short_name);
# Stay connected! (We pass the db handle around in $r->pnotes)
#$dbh->disconnect;
# If nothing found, hotel id is probably invalid
unless ($hotel_id) {
$r->log->error("Invalid hotel name!
(short_name=$short_name) ",
$r->the_request);
# ted fakt nevim, co vratit, jeste se na to kouknu
(treba NOT_FOUND?)
#return BAD_REQUEST;
$r->args("error=invalid_hotel_id");
$r->uri("/error.html");
return DECLINED;
}
# If hotel has a directory with its own design, return something
# like /hotel-2/index.html otherwise return just /index.html
unless ($custom_page) {
my $new_uri = @rest ? "/" . join("/", @rest) :
"/index.html";
$r->uri($new_uri);
}
return DECLINED;
}
1;
__END__
Re: PerlTransHandler & EmbperlObject problem
Posted by Gerald Richter <ri...@ecos.de>.
Hi,
>
> I'm sorry, I had to rewrite everything from scratch (not only because
> of EO problems) and I cann't bring the previous version into the
> testable state in reasonable amount of time. I tried to make a small
> test case but it seems to work now. However I'm still experiencing
> strange problems that look like server is caching more than it should,
> my original problem with EO could have the same reason. I'll look into
> it next week or so and try to make a small reproducible example if I
> can.
>
Thanks for the feedback,
if you do any further investigation, please use the newest CVS version,
because there are some cacheing/ISA issues already fixed.
Gerald
Re: PerlTransHandler & EmbperlObject problem
Posted by Gerald Richter <ri...@ecos.de>.
Robert,
sorry that it take so long until I can answer, but I was very busy and I
wanted try it out on my own first.
> I noticed exactly the same behaviour when EO is used with
> PerlInitHandler Apache::Reload - this probably indicates there's
> something wrong in EO.
>
> Anyway, deadline is too close. We finally redid things in Embperl and
> plain old Perl objects and it worked. We'll try back EO in few weeks.
>
I have tried Apache::Reload and a PerlTransHandler which simply returns -1
(which means DECLINED) and both works here for me without problems together
with EmbperlObject.
I would like to track this down before the next release if possible, but I
need your help. You have to provide more informations. There must be
something special what you do, which causes the problem. It would be great
if you could provide a small example along with a embperl.log with a good
and bad request. Maybe it would be already enought if you can send me a
logfile of a failed request.
Gerald
> - Robert
>
> Robert wrote:
> >
> > I'm using custom PerlTransHandler and while with Embperl it worked OK,
> > with EmbperlObject it does funny things. When I comment PerlTransHandler
> > out, it works again, but in my test case the handler just returns
> > DECLINED. The exact problem is this: after server restart, first time I
> > load the URL I get the right result and embperl log has the usual stuff.
> > Then after first reload it just say 'File not found', nothing is written
> > to the embperl log and apache error log says 'file not found'. Does
> > anybody have any idea what went wrong? Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
>
Re: PerlTransHandler & EmbperlObject problem
Posted by Robert <ro...@robert.cz>.
I noticed exactly the same behaviour when EO is used with
PerlInitHandler Apache::Reload - this probably indicates there's
something wrong in EO.
Anyway, deadline is too close. We finally redid things in Embperl and
plain old Perl objects and it worked. We'll try back EO in few weeks.
- Robert
Robert wrote:
>
> I'm using custom PerlTransHandler and while with Embperl it worked OK,
> with EmbperlObject it does funny things. When I comment PerlTransHandler
> out, it works again, but in my test case the handler just returns
> DECLINED. The exact problem is this: after server restart, first time I
> load the URL I get the right result and embperl log has the usual stuff.
> Then after first reload it just say 'File not found', nothing is written
> to the embperl log and apache error log says 'file not found'. Does
> anybody have any idea what went wrong? Thanks.
Re: PerlTransHandler & EmbperlObject problem
Posted by Gerald Richter <ri...@ecos.de>.
> In the past I had sometimes problems with the symbolic constants. Maybe it
> helps to return 403 instead of DECLINED and 0 instead of OK, it's just a
> try...
Oops, must be -1 instead of DECLINED (and not 403!)
Gerald
>
> How is exactly the "file not found" message in the error log? Could you
cut
> and paste it, that helps me to see from where it comes.
>
> Gerald
>
> -------------------------------------------------------------
> Gerald Richter ecos electronic communication services gmbh
> Internetconnect * Webserver/-design/-datenbanken * Consulting
>
> Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
> E-Mail: richter@ecos.de Voice: +49 6133 925151
> WWW: http://www.ecos.de Fax: +49 6133 925152
> -------------------------------------------------------------
>
> ----- Original Message -----
> From: "Robert" <ro...@robert.cz>
> To: <em...@perl.apache.org>
> Sent: Monday, January 08, 2001 7:14 PM
> Subject: Re: PerlTransHandler & EmbperlObject problem
>
>
> > Gerald Richter wrote:
> > >
> > > I don't have the time to look at it now, but I think your transhandler
> > > should return OK, instead of DECLINED, but I am not quite sure.
> >
> > Eagle book says DECLINED since I don't want to do the actual
> > translation, I expect the standard handler does it. Anyway, even minimal
> > translation handler like this doesn't work:
> >
> >
> >
> > package NetBooking::StripHotelName;
> >
> > use strict;
> > use Apache::Constants qw/:common BAD_REQUEST/;
> > use Apache::Log();
> > use DBI;
> >
> > sub handler {
> > my $r = shift;
> >
> > $r->filename($r->document_root . $r->uri);
> > return OK;
> > }
> >
> > 1;
> >
> > __END__
> >
> >
> >
> > I'm going to find some temporary hack for tomorow demo.
> >
> > - Robert
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
>
Re: PerlTransHandler & EmbperlObject problem
Posted by Gerald Richter <ri...@ecos.de>.
In the past I had sometimes problems with the symbolic constants. Maybe it
helps to return 403 instead of DECLINED and 0 instead of OK, it's just a
try...
How is exactly the "file not found" message in the error log? Could you cut
and paste it, that helps me to see from where it comes.
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
----- Original Message -----
From: "Robert" <ro...@robert.cz>
To: <em...@perl.apache.org>
Sent: Monday, January 08, 2001 7:14 PM
Subject: Re: PerlTransHandler & EmbperlObject problem
> Gerald Richter wrote:
> >
> > I don't have the time to look at it now, but I think your transhandler
> > should return OK, instead of DECLINED, but I am not quite sure.
>
> Eagle book says DECLINED since I don't want to do the actual
> translation, I expect the standard handler does it. Anyway, even minimal
> translation handler like this doesn't work:
>
>
>
> package NetBooking::StripHotelName;
>
> use strict;
> use Apache::Constants qw/:common BAD_REQUEST/;
> use Apache::Log();
> use DBI;
>
> sub handler {
> my $r = shift;
>
> $r->filename($r->document_root . $r->uri);
> return OK;
> }
>
> 1;
>
> __END__
>
>
>
> I'm going to find some temporary hack for tomorow demo.
>
> - Robert
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
>
Re: PerlTransHandler & EmbperlObject problem
Posted by Robert <ro...@robert.cz>.
Gerald Richter wrote:
>
> I don't have the time to look at it now, but I think your transhandler
> should return OK, instead of DECLINED, but I am not quite sure.
Eagle book says DECLINED since I don't want to do the actual
translation, I expect the standard handler does it. Anyway, even minimal
translation handler like this doesn't work:
package NetBooking::StripHotelName;
use strict;
use Apache::Constants qw/:common BAD_REQUEST/;
use Apache::Log();
use DBI;
sub handler {
my $r = shift;
$r->filename($r->document_root . $r->uri);
return OK;
}
1;
__END__
I'm going to find some temporary hack for tomorow demo.
- Robert
Re: PerlTransHandler & EmbperlObject problem
Posted by Gerald Richter <ri...@ecos.de>.
Robert,
I don't have the time to look at it now, but I think your transhandler
should return OK, instead of DECLINED, but I am not quite sure.
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------
----- Original Message -----
From: "Robert" <ro...@robert.cz>
To: <em...@perl.apache.org>
Sent: Monday, January 08, 2001 5:18 PM
Subject: Re: PerlTransHandler & EmbperlObject problem
> The reload problem manifests itself even with this minimal
> PerlTransHandler. I'd think if it just returns DECLINED, default Apache
> handler does the right thing, but apparently it doesn't. I don't
> understand why and today's the deadline. Any help, please?
>
> - Robert
>
>
> handler
> =======
>
> package NetBooking::StripHotelName;
>
> use strict;
> use Apache::Constants qw/:common BAD_REQUEST/;
>
> sub handler {
> my $r = shift;
> return DECLINED;
> }
>
> 1;
>
> __END__
>
>
>
============================================================================
=
>
> I'm using custom PerlTransHandler and while with Embperl it works OK,
> with EmbperlObject it does funny things. When I comment PerlTransHandler
> out, it works again. The exact problem is this: after server restart,
> first time I
> load the URL I get the right result and embperl log has the usual stuff.
> Then after first reload it just say 'File not found', nothing is written
> to the embperl log and apache error log says 'file not found'. Does
> anybody have any idea what went wrong? Thanks.
>
> - Robert
>
>
> url
> ===
> http://nbczsecure/hotel-2/index.html
>
> config
> ======
> <VirtualHost nbczsecure>
> ServerAdmin germic
> DocumentRoot
> /mnt/web/projekty/netbooking/current/nbczsecure/doc
> ServerName nbczsecure
> ErrorLog logs/nbczsecure.error_log
> CustomLog logs/nbczsecure.access_log combined
> # PerlSetEnv EMBPERL_DEBUG 10477
> PerlTransHandler NetBooking::StripHotelName
> <FilesMatch ".*\.html$">
> PerlSetEnv EMBPERL_OBJECT_BASE base.html
> PerlSetEnv EMBPERL_OBJECT_FALLBACK index.html
> # PerlSetEnv EMBPERL_FILESMATCH "\.html$|\.epl$"
> SetHandler perl-script
> PerlHandler HTML::EmbperlObject
> Options ExecCGI
> </FilesMatch>
> </VirtualHost>
>
>
> error log
> =========
> [Mon Jan 8 15:01:57 2001] [error] EmbperlObject searched
>
';/mnt/web/projekty/netbooking/current/nbczsecure/doc/hotel-2;/mnt/web/proje
kty/netbooking/current/nbczsecure/doc'
>
> /base.html
> ==========
> [-
> sub new {
> my $self = shift;
>
> $self->{dbh} = $req_rec->pnotes('DBH') || 'no dbh';
> $self->{hotel_id} = $req_rec->pnotes('HOTEL_ID') || 'no
> hid';
> $self->{short_name} = $req_rec->pnotes('SHORT_NAME') ||
> 'no name';
> }
> # ... tvuj stuff
> -]
>
> <body>
>
> [- Execute '*' -]
>
> <hr>
> dbh = [+ $r->{dbh} +]<br>
> hotel_id = [+ $r->{$hotel_id} +]<br>
> short_name = [+ $r->{short_name} +]<br>
>
> </body>
>
>
> /hotel-2/index.html
> ===================
> [-
> $r = shift;
> $r->new;
> -]
>
> <h1 style='color: red'>Booking form for hotel *[+ $r->{short_name}
> +]*</h1>
>
>
> handler
> =======
> package NetBooking::StripHotelName;
>
> use strict;
> use Apache::Constants qw/:common BAD_REQUEST/;
> use Apache::Log();
> use DBI;
>
> sub handler {
> my $r = shift;
>
> # Don't connect if it's just a picture or styleshit
> return DECLINED if $r->uri =~ /\.gif$/ or $r->uri =~ /\.jpg$/ or
> $r->uri =~ /\.css$/;
>
> my ($junk, $short_name, @rest) = split '/', $r->uri;
>
> # Fetch the hotel id from the database
> #my $dbh = DBI->connect('DBI:Pg:dbname=nbcz', '', '', {
> RaiseError =>
> 1, AutoCommit => 1 });
> #my ($hotel_id, $short_name, $custom_page) =
> $dbh->selectrow_array(
> # "SELECT id,short_name,custom_page FROM hotel WHERE
> short_name = ?",
> {}, $short_name);
> my ($dbh, $hotel_id, $short_name, $custom_page) = (undef, 1,
> 'hotel-1',
> 1);
> #$r->log->error("DEBUG: hotel_id=$hotel_id,
> short_name=$short_name,
> custom_page=$custom_page ", $r->the_request);
> $r->pnotes('DBH' => $dbh);
> $r->pnotes('HOTEL_ID' => $hotel_id);
> $r->pnotes('SHORT_NAME' => $short_name);
> # Stay connected! (We pass the db handle around in $r->pnotes)
> #$dbh->disconnect;
>
> # If nothing found, hotel id is probably invalid
> unless ($hotel_id) {
> $r->log->error("Invalid hotel name!
> (short_name=$short_name) ",
> $r->the_request);
> # ted fakt nevim, co vratit, jeste se na to kouknu
> (treba NOT_FOUND?)
> #return BAD_REQUEST;
> $r->args("error=invalid_hotel_id");
> $r->uri("/error.html");
> return DECLINED;
> }
>
> # If hotel has a directory with its own design, return something
> # like /hotel-2/index.html otherwise return just /index.html
> unless ($custom_page) {
> my $new_uri = @rest ? "/" . join("/", @rest) :
> "/index.html";
> $r->uri($new_uri);
> }
> return DECLINED;
> }
>
> 1;
>
> __END__
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
>
Re: PerlTransHandler & EmbperlObject problem
Posted by Robert <ro...@robert.cz>.
The reload problem manifests itself even with this minimal
PerlTransHandler. I'd think if it just returns DECLINED, default Apache
handler does the right thing, but apparently it doesn't. I don't
understand why and today's the deadline. Any help, please?
- Robert
handler
=======
package NetBooking::StripHotelName;
use strict;
use Apache::Constants qw/:common BAD_REQUEST/;
sub handler {
my $r = shift;
return DECLINED;
}
1;
__END__
=============================================================================
I'm using custom PerlTransHandler and while with Embperl it works OK,
with EmbperlObject it does funny things. When I comment PerlTransHandler
out, it works again. The exact problem is this: after server restart,
first time I
load the URL I get the right result and embperl log has the usual stuff.
Then after first reload it just say 'File not found', nothing is written
to the embperl log and apache error log says 'file not found'. Does
anybody have any idea what went wrong? Thanks.
- Robert
url
===
http://nbczsecure/hotel-2/index.html
config
======
<VirtualHost nbczsecure>
ServerAdmin germic
DocumentRoot
/mnt/web/projekty/netbooking/current/nbczsecure/doc
ServerName nbczsecure
ErrorLog logs/nbczsecure.error_log
CustomLog logs/nbczsecure.access_log combined
# PerlSetEnv EMBPERL_DEBUG 10477
PerlTransHandler NetBooking::StripHotelName
<FilesMatch ".*\.html$">
PerlSetEnv EMBPERL_OBJECT_BASE base.html
PerlSetEnv EMBPERL_OBJECT_FALLBACK index.html
# PerlSetEnv EMBPERL_FILESMATCH "\.html$|\.epl$"
SetHandler perl-script
PerlHandler HTML::EmbperlObject
Options ExecCGI
</FilesMatch>
</VirtualHost>
error log
=========
[Mon Jan 8 15:01:57 2001] [error] EmbperlObject searched
';/mnt/web/projekty/netbooking/current/nbczsecure/doc/hotel-2;/mnt/web/projekty/netbooking/current/nbczsecure/doc'
/base.html
==========
[-
sub new {
my $self = shift;
$self->{dbh} = $req_rec->pnotes('DBH') || 'no dbh';
$self->{hotel_id} = $req_rec->pnotes('HOTEL_ID') || 'no
hid';
$self->{short_name} = $req_rec->pnotes('SHORT_NAME') ||
'no name';
}
# ... tvuj stuff
-]
<body>
[- Execute '*' -]
<hr>
dbh = [+ $r->{dbh} +]<br>
hotel_id = [+ $r->{$hotel_id} +]<br>
short_name = [+ $r->{short_name} +]<br>
</body>
/hotel-2/index.html
===================
[-
$r = shift;
$r->new;
-]
<h1 style='color: red'>Booking form for hotel *[+ $r->{short_name}
+]*</h1>
handler
=======
package NetBooking::StripHotelName;
use strict;
use Apache::Constants qw/:common BAD_REQUEST/;
use Apache::Log();
use DBI;
sub handler {
my $r = shift;
# Don't connect if it's just a picture or styleshit
return DECLINED if $r->uri =~ /\.gif$/ or $r->uri =~ /\.jpg$/ or
$r->uri =~ /\.css$/;
my ($junk, $short_name, @rest) = split '/', $r->uri;
# Fetch the hotel id from the database
#my $dbh = DBI->connect('DBI:Pg:dbname=nbcz', '', '', {
RaiseError =>
1, AutoCommit => 1 });
#my ($hotel_id, $short_name, $custom_page) =
$dbh->selectrow_array(
# "SELECT id,short_name,custom_page FROM hotel WHERE
short_name = ?",
{}, $short_name);
my ($dbh, $hotel_id, $short_name, $custom_page) = (undef, 1,
'hotel-1',
1);
#$r->log->error("DEBUG: hotel_id=$hotel_id,
short_name=$short_name,
custom_page=$custom_page ", $r->the_request);
$r->pnotes('DBH' => $dbh);
$r->pnotes('HOTEL_ID' => $hotel_id);
$r->pnotes('SHORT_NAME' => $short_name);
# Stay connected! (We pass the db handle around in $r->pnotes)
#$dbh->disconnect;
# If nothing found, hotel id is probably invalid
unless ($hotel_id) {
$r->log->error("Invalid hotel name!
(short_name=$short_name) ",
$r->the_request);
# ted fakt nevim, co vratit, jeste se na to kouknu
(treba NOT_FOUND?)
#return BAD_REQUEST;
$r->args("error=invalid_hotel_id");
$r->uri("/error.html");
return DECLINED;
}
# If hotel has a directory with its own design, return something
# like /hotel-2/index.html otherwise return just /index.html
unless ($custom_page) {
my $new_uri = @rest ? "/" . join("/", @rest) :
"/index.html";
$r->uri($new_uri);
}
return DECLINED;
}
1;
__END__