Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Embperl

Being called twice

 

 

ModPerl embperl RSS feed   Index | Next | Previous | View Threaded


kat_lists at katspace

Oct 12, 2006, 2:57 PM

Post #1 of 4 (1807 views)
Permalink
Being called twice

I am using Embperl::Object 2.2.0 (with mod_perl 2.0.2 on Apache 2.0.58)
I've been trying to implement an email form, and have been completely
baffled because the mail was always being sent twice.
Trying to track things down, I put some warning calls in my epwebapp.pl
file, and it seems as if get_recipe is being called twice:
once from Embperl::Object and once from Embperl::Req
This is actually happening for all my files, not just the mail-form one,
but I never noticed it before because all the pages were displaying
fine; it wasn't until there was something which had additional effects
(sending mail) that I noticed this was happening.

Why is this happening? Is there something I am doing wrong, some
additional setting or parameter which needs to be set so that a page is
only executed once?

My base.epl file is very simple: it just consists of one line:

[- Execute ('*') -]

All my templating is done with custom XSLT files; one of the things that
my get_recipe does is that when the requested file is a html file,
it gives a custom recipe which does XSLT processing (with the desired
XSLT template file) followed by Embperl processing (the opposite to
EmbperlXSLT, which does Embperl processing followed by XSLT processing).

I am completely baffled, and very frustrated.

Kathryn Andersen
--
_--_|\ | Kathryn Andersen <http://www.katspace.com>
/ \ |
\_.--.*/ | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
v |
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha! | -> Earth -> Sol -> Milky Way Galaxy -> Universe

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe [at] perl
For additional commands, e-mail: embperl-help [at] perl


richter at ecos

Oct 19, 2006, 1:10 PM

Post #2 of 4 (1677 views)
Permalink
RE: Being called twice [In reply to]

>
> I am using Embperl::Object 2.2.0 (with mod_perl 2.0.2 on
> Apache 2.0.58) I've been trying to implement an email form,
> and have been completely baffled because the mail was always
> being sent twice.
> Trying to track things down, I put some warning calls in my
> epwebapp.pl file, and it seems as if get_recipe is being called twice:
> once from Embperl::Object and once from Embperl::Req


get_recipe is called for every file that Embperl processes.

Embperl::Object loads the file and executes the [! !] blocks, while during
the request the other blocks are executed. For both types of file access
get_recipe is called. Since get_recipe is only intened to return a recipe
and not to do any processing, this should be no problem at all, but gives
you the chance to change your recipe during the request initialisation.

I don't see why your mail is sent twice, because of the double call to
get_recipe. Do you send your mail inside of get_recipe? If yes, you should
use an application object instead and use the init method to do such work.

Gerald




** Virus checked by BB-5000 Mailfilter **


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe [at] perl
For additional commands, e-mail: embperl-help [at] perl


kat_lists at katspace

Oct 19, 2006, 2:16 PM

Post #3 of 4 (1657 views)
Permalink
Re: Being called twice [In reply to]

On Thu, Oct 19, 2006 at 10:10:01PM +0200, Gerald Richter wrote:
> >
> > I am using Embperl::Object 2.2.0 (with mod_perl 2.0.2 on
> > Apache 2.0.58) I've been trying to implement an email form,
> > and have been completely baffled because the mail was always
> > being sent twice.
> > Trying to track things down, I put some warning calls in my
> > epwebapp.pl file, and it seems as if get_recipe is being called twice:
> > once from Embperl::Object and once from Embperl::Req
>
> get_recipe is called for every file that Embperl processes.

Yes, I know; the debug code I put in there was giving information about
the file that was being processed, and I was puzzled and concerned that
the .html file containg the email code was being called twice.

> Embperl::Object loads the file and executes the [! !] blocks, while during
> the request the other blocks are executed. For both types of file access
> get_recipe is called.

Ah. There are [! and [- and [+ blocks in the file; that explains it.

> Since get_recipe is only intened to return a recipe
> and not to do any processing, this should be no problem at all, but gives
> you the chance to change your recipe during the request initialisation.

Why would one want to do that? And how?

> I don't see why your mail is sent twice, because of the double call to
> get_recipe. Do you send your mail inside of get_recipe?

Certainly not!

> If yes, you should
> use an application object instead and use the init method to do such work.

I'm not following you here.

Kathryn Andersen
--
_--_|\ | Kathryn Andersen <http://www.katspace.com>
/ \ |
\_.--.*/ | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
v |
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha! | -> Earth -> Sol -> Milky Way Galaxy -> Universe

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe [at] perl
For additional commands, e-mail: embperl-help [at] perl


richter at ecos

Oct 23, 2006, 8:26 PM

Post #4 of 4 (1658 views)
Permalink
RE: Being called twice [In reply to]

>
> > Since get_recipe is only intened to return a recipe and not
> to do any
> > processing, this should be no problem at all, but gives you
> the chance
> > to change your recipe during the request initialisation.
>
> Why would one want to do that? And how?
>

For example you might want to look at the passed parameters and decide
afterwards if you want to deliver HTML or XML or whatever.

>
> > If yes, you should
> > use an application object instead and use the init method
> to do such work.
>
> I'm not following you here.
>

You can set Embperl_Object_App to a filename that contains Perl code. The
init method of this file is called before any other page and allows you to
modify the request, for example which file to serve and to do any
processing. This allows you to separate code and presentation.

Gerald



** Virus checked by BB-5000 Mailfilter **


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe [at] perl
For additional commands, e-mail: embperl-help [at] perl

ModPerl embperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.