You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Kee Hinckley <na...@somewhere.com> on 2002/10/11 02:01:45 UTC

Erasing the output

Embperl 1.3.4.

I have a situation where I discover half way through a file that I 
want to abort the current page and display something else entirely. 
I'm not displaying pages until the everything has run, so things are 
clearly cached somewhere.  Is there away to delete the cache?

E.g.

	... bunch of html and code ...
	[-
		if (something wrong)
			erase all that stuff
			Execute(error page)
		}
	-]


On a rather related subject.  A while ago we discussed exception 
handling.  Has anyone thought of a way of doing that in a page?

	[! try { !]
does not appear to work (and there is the issue of dealing with the 
output problem mentioned above even if it did).

I'd love to see the Error package builtin as [$ $] keywords.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

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


Re: Erasing the output

Posted by Kee Hinckley <na...@somewhere.com>.
>     try {
>         my $rval = Execute({ inputfile => '*', errors => \@errors, 
>options => HTML::Embperl::optReturnError});
>         if ($rval || @errors) {
>             $this->Error(0);
>             Execute("$ENV{DOCUMENT_ROOT}/error.html", $rval, @errors);
>         }

A slight correction to this, which I just came across.  You would 
probably want to do

	if ($rval) {
		...
	} elsif (@errors) {
	}

If $rval isn't set, and there is something in @errors, it probably 
means that somebody threw a warning.  And in that case you probably 
don't want to display a whole web page (at the bottom of the previous 
web page!), but want to deal with the problem some other way.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

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


Re: Erasing the output

Posted by Kee Hinckley <na...@somewhere.com>.
At 8:03 AM +0200 10/16/02, Gerald Richter wrote:
>  > At Fri, 11 Oct 2002 06:55:10 +0200, Gerald Richter wrote:
>>  > Some way of exception handling would be nice, that's true. I put it
>>  > on the todo list
>>
>>  i've always thought that "just" allowing die/eval do what they
>>  normally do would be a nice way of handling both "but i want to exit()
>>  to this particular level" and Execute({errors => \@a}) (since error is
>>  in $@).
>>

I'm not entirely sure what was meant by that.

>
>Basicly yes, but I need to give this errors => \@a stuff some more testing
>and see how it interacts with die

Execute works well with throw, which is I assume is equivalent.  I'm 
currently doing the following in my EmbperlObject templates.

     $this = shift;
     my (@errors, $rval);
     try {
         my $rval = Execute({ inputfile => '*', errors => \@errors, 
options => HTML::Embperl::optReturnError});
         if ($rval || @errors) {
             $this->Error(0);
             Execute("$ENV{DOCUMENT_ROOT}/error.html", $rval, @errors);
         }
     } otherwise {
         $this->Error(0);
         Execute("$ENV{DOCUMENT_ROOT}/error.html", 500, $_[0]->{-text});
     };


If I get an error in the page being executed I simply throw the 
error, and that causes the error handling page to be executed with 
the appropriate parameters.

Note that I've been unable to get
	[! use Error qw:try); !]
	[* try { *]
to work at all.  I just get a blank page.
-- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

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


Re: Erasing the output

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

> At Fri, 11 Oct 2002 06:55:10 +0200, Gerald Richter wrote:
> > Some way of exception handling would be nice, that's true. I put it
> > on the todo list
>
> i've always thought that "just" allowing die/eval do what they
> normally do would be a nice way of handling both "but i want to exit()
> to this particular level" and Execute({errors => \@a}) (since error is
> in $@).
>

Basicly yes, but I need to give this errors => \@a stuff some more testing
and see how it interacts with die

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: Erasing the output

Posted by Angus Lees <gu...@inodes.org>.
At Fri, 11 Oct 2002 06:55:10 +0200, Gerald Richter wrote:
> Some way of exception handling would be nice, that's true. I put it
> on the todo list

i've always thought that "just" allowing die/eval do what they
normally do would be a nice way of handling both "but i want to exit()
to this particular level" and Execute({errors => \@a}) (since error is
in $@).

-- 
 - Gus

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


Re: Erasing the output

Posted by Gerald Richter <ri...@ecos.de>.
> Embperl 1.3.4.
>
> I have a situation where I discover half way through a file that I
> want to abort the current page and display something else entirely.
> I'm not displaying pages until the everything has run, so things are
> clearly cached somewhere.

Yes

>Is there away to delete the cache?

Not from Perl

>From C there are three functions (in 1.3.4) oBegin, oCommit and oRollback,
which do what you want to do. Would be necessary to make them access able
from Perl.

>
> On a rather related subject.  A while ago we discussed exception
> handling.  Has anyone thought of a way of doing that in a page?
>
> [! try { !]
> does not appear to work (and there is the issue of dealing with the
> output problem mentioned above even if it did).

Not tried it, but

[* try { *]

should work, also the output is not discarded in case of an exception.

>
> I'd love to see the Error package builtin as [$ $] keywords.

Some way of exception handling would be nice, that's true. I put it on the
todo list

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