You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Dan Manley <dm...@spotnikmobile.com> on 2004/06/22 17:34:03 UTC
errors handling in HTML::Embperl::Mail
Hi,
I'm using embperl 1.3.6 on RedHat linux 9 with Apache 1.3.31 with
mod_perl 1.29. I'm encountering some strange behaviour with the mailing
package. I have an embperl file calling a method in a package I'm
written. This method does some work (processes a credit-card payment)
and returns the results as a hash reference. Then the .epl does a
little more work and calls HTML::Embperl::Mail::Execute() to send a
notice to the customer.
The strangeness I'm seeing is that the HTML::Embperl::Execute() called
inside HTML::Embperl::Mail::Execute() successfully parses and rendered
the email template but returns a non-empty errors array with a string
identical to a warn debugging message issued in the credit card
processing package. If I comment out the warn statements in the
package, the mailer works. How is it that Embperl (in the C code?) has
access to the warn message and uses it to claim an error message?
Dan
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Re[2]: Trouble with catching output of prcodures
Posted by Gerald Richter <ri...@ecos.de>.
Sherwin wrote:
> On Thu, Jul 08, 2004 at 02:16:53PM +0200, Gerald Richter wrote:
>> In 1.3.6 "die" only ends the current block, not the file. If you
>> want to end processing of the file, you have to use exit, but exit
>> only ends the proessing of the current file, the caller will still
>> continue. You have to catch it somehow there.
>
> Gerald,
>
> By exit, do you mean CORE::exit? Can the poster use Apache::exit to
> achieve what he wants in 1.3.6?
>
Embperl overloads exit, so when you do call just exit Embperl will handle it
for you (the same will happen if you call Apache::exit).
If you call CORE::exit the process (Apache child) will exit imediately. You
normaly don't want this
Gerald
---------------------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de/ Fax: +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Re[2]: Trouble with catching output of prcodures
Posted by Sherwin <sh...@saturn.emc.com.ph>.
On Thu, Jul 08, 2004 at 02:16:53PM +0200, Gerald Richter wrote:
> In 1.3.6 "die" only ends the current block, not the file. If you want to end
> processing of the file, you have to use exit, but exit only ends the
> proessing of the current file, the caller will still continue. You have to
> catch it somehow there.
Gerald,
By exit, do you mean CORE::exit? Can the poster use Apache::exit to
achieve what he wants in 1.3.6?
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Re[2]: Trouble with catching output of prcodures
Posted by Gerald Richter <ri...@ecos.de>.
Hi,
>
> title.epl
> [- die "Die in title.epl, " -]
> Test
>
In 1.3.6 "die" only ends the current block, not the file. If you want to end
processing of the file, you have to use exit, but exit only ends the
proessing of the current file, the caller will still continue. You have to
catch it somehow there.
Embperl 2 has a better die and exit handling (see README.v2)
Gerald
---------------------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
IT-Securitylosungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de/ Fax: +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re[2]: Trouble with catching output of prcodures
Posted by Filin <fi...@bk.ru>.
Thank you, Gerald. Your recipe is perfectly good for me, but I have new
questions about catching output (Embperl 1.3.6).
Let us assume that we have next three files:
some.epl
Some text (Content does not matter)
title.epl
[- die "Die in title.epl, " -]
Test
test.epl
<H1>[- Execute('title.epl'); # should die there -]</H1>
[-
Execute({
inputfile=>"some.html",
output=>\$res,
});
#print OUT $res;
-]
<hr>
I am alive. Why!?!
I thought that execution of test.html should die in the title.epl.
However, it doesn't.
Well, it will die, but _only_ if we comment the "output=>\$res" in the test.epl.
Moreover, the most strange for me: if we uncomment "#print OUT $res", we'll
discover that there are lost error messages in the $res. Why it is so, if we
didn't try to catch output of "Execute('title.epl')"?
I dont understand what's happening. :(
Could some kind person explain it for me?
Thanks.
---
Filin
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Trouble with catching output of prcodures
Posted by Gerald Richter <ri...@ecos.de>.
Filin wrote:
> I have a trouble with using of output of embperl procedures. E.g.
> there is following declaration in some file: [$ sub somesub $]Some
> text[$ endsub $]
>
> If I want to catch output of somesub, I can:
> Execute({inputfile=>"file", import=>0});
> Execute({inputfile=>"file", sub=>'somesub', output=>\$str});
>
> But what if I need to use something like:
> $file=Execute({object=>"file"});
> $file->somesub();
>
> How can I catch output in this case?
> It is possible of course just to replace [$ sub somesub ... $] with
> [! sub somesub {...} !],
> but I would be VERY glad to hear that it isn't the only decision.
>
You cannot directly catch the output of a method, but you can create a
wrapper:
[!
sub wrapper
{
$param[0]->$param[1]() ;
}
!]
call it via
Execute({inputfile=>"file", sub=>'wrapper', output=>\$str, param => [$file,
'somesub']});
Gerald
---------------------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
IT-Securitylosungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de/ Fax: +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Trouble with catching output of prcodures
Posted by Filin <fi...@bk.ru>.
I have a trouble with using of output of embperl procedures. E.g. there is following declaration in some file:
[$ sub somesub $]Some text[$ endsub $]
If I want to catch output of somesub, I can:
Execute({inputfile=>"file", import=>0});
Execute({inputfile=>"file", sub=>'somesub', output=>\$str});
But what if I need to use something like:
$file=Execute({object=>"file"});
$file->somesub();
How can I catch output in this case?
It is possible of course just to replace [$ sub somesub ... $] with [! sub somesub {...} !],
but I would be VERY glad to hear that it isn't the only decision.
Please help me.
(I use Embperl 1.3.6)
---
Owl
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
IIS PATH_TRANSLATED fix
Posted by Maurice McCabe <mm...@orbsoft.com>.
I am installing on a shared Windows Server running IIS and want to be
able to run embpcgi.pl as a regular CGI script (no file extension
mapping is available, since not supported in this ISP's shared
environment). By default, in CGI mode, IIS does not generate the correct
value for PATH_TRANSLATED, so I created a fix that gets around the
problem that I would like to share.
Adding the following to your embpcgi.pl will allow you to run on IIS
using a URL like:
http://www.mycompany.com/cgi-bin/embpcgi.pl/myembperlapplication/index.h
tm
(This fix still behaves correctly when using file extension mapping
allowing you to run in either mode)
BEGIN {
if ($^O eq "MSWin32" && $#ARGV == -1) {
my $SCRIPT_FILENAME=$0;
my ($path_info) = $ENV{PATH_INFO} =~ /^$ENV{SCRIPT_NAME}(.*)$/;
my $SCRIPT_NAME = $ENV{SCRIPT_NAME};
$SCRIPT_NAME =~ s/\//\\\\/g;
my ($document_root) = $SCRIPT_FILENAME =~ /^(.*)$SCRIPT_NAME.*/;
$ENV{PATH_TRANSLATED}=$document_root . $path_info;
}
}
This fix is not restricted for use with Embperl or even with Perl (may
involve more coding if rewritten in another language). It should work
for any CGI application running on IIS that uses PATH_TRANSLATED.
Hope this helps some folks out there that have been looking for this.
BTW: With this fix, I can confirm that Embperl will run in a shared
Windows environment running IIS and Perl. (Requires only FTP and setting
of @INC to install. Must have precompiled non-modperl version of Embperl
for windows available from Randy Kobes)
Maurice
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: errors handling in HTML::Embperl::Mail
Posted by Gerald Richter <ri...@ecos.de>.
>
> The strangeness I'm seeing is that the HTML::Embperl::Execute() called
> inside HTML::Embperl::Mail::Execute() successfully parses and rendered
> the email template but returns a non-empty errors array with a string
> identical to a warn debugging message issued in the credit card
> processing package. If I comment out the warn statements in the
> package, the mailer works. How is it that Embperl (in the C code?)
> has access to the warn message and uses it to claim an error message?
>
Embperl gather all errors and warining messages that occurs during the
processing of an Embperl request in the error array. It does not make a
difference if this errors or warings occurs inside the Emberl page it self
or inside a modul it calls.
The return code from Execute tells you if there is only a warning or an
error (on error Execute returns a non zero value)
Gerald
---------------------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de/ Fax: +49 6133 939-333
---------------------------------------------------------------------------
ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info
---------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org