You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Gavin Carr <ga...@openfusion.com.au> on 2001/05/21 02:34:37 UTC

Executing file that doesn't exist

Hi Gerald et al,

I want to be able to do an Embperl::Execute on a file that potentially
doesn't exist and catch the error (within EmbperlObject, so it's not
trivial to just do a -f on the file). I've tried the obvious things -
the 'errors' parameter, $optDisableEmbperlErrorPage, $optReturnError,
etc - but I keep getting Embperl 'Not found <filename>' errors. Is there
a way around this? 

Alternatively, is there a way of accessing the search path EmbperlObject
sets up so I can check for the file manually?

Cheers,
Gavin


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


Re: Executing file that doesn't exist

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

> 
> Complete success on 1.3.2! Thanks. Does/will version 2.0x handle this 
> similarly?
> 

Yes, this will also work on 2.0. The patch will go into 1.3.3 and 2.0b3

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 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




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


Re: Executing file that doesn't exist

Posted by Gavin Carr <ga...@openfusion.com.au>.
Hi Gerald,

Complete success on 1.3.2! Thanks. Does/will version 2.0x handle this 
similarly?

Cheers,
Gavin

On Tue, May 22, 2001 at 01:14:18PM +0200, Gerald Richter wrote:
> ok, you are right, my answer was a little bit too quick...
> 
> You need to reset Embperl internals error flag, but you can't. You first
> have to make the following patch: In Embperl.xs line 560, change
> 
> int
> embperl_Error(r,...)
>     tReq * r
> CODE:
>     RETVAL = r -> bError ;
> OUTPUT:
>     RETVAL
> 
> 
> to
> 
> int
> embperl_Error(r,...)
>     tReq * r
> CODE:
>     RETVAL = r -> bError ;
>     if (items > 1)
>         r -> bError = (int)SvIV(ST(1)) ;
> OUTPUT:
>     RETVAL
> 
> 
> After this patch the following code works:
> 
> <body>
> 
> 
> [-
> $r = shift ;
> my $err = $r -> Error ;
> $rc = Execute { inputfile => 'notfound.htm', options => 262144 } ;
> $r -> Error ($err) ;
> 
> -]
> 
> 
> rc = [+ $rc +]<br>
> 
> <p>Done.</p>
> </body></html>
> 
> Gerald

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


Re: Executing file that doesn't exist

Posted by Gerald Richter <ri...@ecos.de>.
>
> I'd tried that without success - the following, for example, doesn't
> work for me:
>
> ----
> <html><body bgcolor="white">
> <p>Executing here:</p>
>
> [- Execute { inputfile => 'foo.html', options => 262144 } -]
>
> <p>Done.</p>
> </body></html>
> ----
>

ok, you are right, my answer was a little bit too quick...

You need to reset Embperl internals error flag, but you can't. You first
have to make the following patch: In Embperl.xs line 560, change

int
embperl_Error(r,...)
    tReq * r
CODE:
    RETVAL = r -> bError ;
OUTPUT:
    RETVAL


to

int
embperl_Error(r,...)
    tReq * r
CODE:
    RETVAL = r -> bError ;
    if (items > 1)
        r -> bError = (int)SvIV(ST(1)) ;
OUTPUT:
    RETVAL


After this patch the following code works:

<body>


[-
$r = shift ;
my $err = $r -> Error ;
$rc = Execute { inputfile => 'notfound.htm', options => 262144 } ;
$r -> Error ($err) ;

-]


rc = [+ $rc +]<br>

<p>Done.</p>
</body></html>


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 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



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


Re: Executing file that doesn't exist

Posted by Gavin Carr <ga...@openfusion.com.au>.
Hi Gerald,

On Tue, May 22, 2001 at 07:33:38AM +0200, Gerald Richter wrote:
> > Yes, I know about EMBPERL_OBJECT_FALLBACK, but here I'm doing an
> > Embperl::Execute (of a component) not the initial
> > EmbperlObject::Execute, so I don't think this applies? An
> > Embperl::Execute fallback option would be really useful here if such a
> > thing does exist ...
> 
> In this case you can set options => HTML::Embperl::optReturnError, then
> Execute doesn't generate an error page, but returns an error code. To get
> the full errormessages, you can use the errors parameter.

I'd tried that without success - the following, for example, doesn't
work for me:

----
<html><body bgcolor="white">
<p>Executing here:</p>
 
[- Execute { inputfile => 'foo.html', options => 262144 } -]
  
<p>Done.</p>
</body></html>
----

I've found it does work now if I set it via EMBPERL_OPTIONS rather than
within the Execute - should the above work or not?

Cheers,
Gavin

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


Re: Executing file that doesn't exist

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

>
> Yes, I know about EMBPERL_OBJECT_FALLBACK, but here I'm doing an
> Embperl::Execute (of a component) not the initial
> EmbperlObject::Execute, so I don't think this applies? An
> Embperl::Execute fallback option would be really useful here if such a
> thing does exist ...
>

In this case you can set options => HTML::Embperl::optReturnError, then
Execute doesn't generate an error page, but returns an error code. To get
the full errormessages, you can use the errors parameter.

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 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




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


Re: Executing file that doesn't exist

Posted by Gavin Carr <ga...@openfusion.com.au>.
Hi Gerald,

On Mon, May 21, 2001 at 06:09:25PM +0200, Gerald Richter wrote:
> you can set EMBPERL_OBJECT_FALLBACK, then this page is execute if a page
> isn't found.

Yes, I know about EMBPERL_OBJECT_FALLBACK, but here I'm doing an
Embperl::Execute (of a component) not the initial
EmbperlObject::Execute, so I don't think this applies? An
Embperl::Execute fallback option would be really useful here if such a
thing does exist ...

> You can get the search path via
> 
> [-
> 
> $r = shift ;
> 
> $path = $r -> Path ;
> 
> -]

Great - if there are no better options I can at least do a search of the
path myself.

Cheers,
Gavin


> ----- Original Message -----
> From: "Gavin Carr" <ga...@openfusion.com.au>
> To: <em...@perl.apache.org>
> Sent: Monday, May 21, 2001 2:34 AM
> Subject: Executing file that doesn't exist
> 
> 
> > Hi Gerald et al,
> >
> > I want to be able to do an Embperl::Execute on a file that potentially
> > doesn't exist and catch the error (within EmbperlObject, so it's not
> > trivial to just do a -f on the file). I've tried the obvious things -
> > the 'errors' parameter, $optDisableEmbperlErrorPage, $optReturnError,
> > etc - but I keep getting Embperl 'Not found <filename>' errors. Is there
> > a way around this?
> >
> > Alternatively, is there a way of accessing the search path EmbperlObject
> > sets up so I can check for the file manually?
> >
> > Cheers,
> > Gavin
> >
> >
> > ---------------------------------------------------------------------
> > 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: Executing file that doesn't exist

Posted by Gerald Richter <ri...@ecos.de>.
Hi,

you can set EMBPERL_OBJECT_FALLBACK, then this page is execute if a page
isn't found.

You can get the search path via

[-

$r = shift ;

$path = $r -> Path ;

-]

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 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------

----- Original Message -----
From: "Gavin Carr" <ga...@openfusion.com.au>
To: <em...@perl.apache.org>
Sent: Monday, May 21, 2001 2:34 AM
Subject: Executing file that doesn't exist


> Hi Gerald et al,
>
> I want to be able to do an Embperl::Execute on a file that potentially
> doesn't exist and catch the error (within EmbperlObject, so it's not
> trivial to just do a -f on the file). I've tried the obvious things -
> the 'errors' parameter, $optDisableEmbperlErrorPage, $optReturnError,
> etc - but I keep getting Embperl 'Not found <filename>' errors. Is there
> a way around this?
>
> Alternatively, is there a way of accessing the search path EmbperlObject
> sets up so I can check for the file manually?
>
> Cheers,
> Gavin
>
>
> ---------------------------------------------------------------------
> 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