Mailing List Archive

help resolve complex mod_perl EPL framework
I am using embperl in a non-standard way to take care of old perl code which
has html embedded in it via print statements.
Here is a summarized top-to-bottom (1->2->3) overview of the architecture:

1. legacy.phtml
HTML::Embperl::Execute({ inputfile => 'legacy_pm.epl',
param => ['legacy.pm'], fdat => \%IN, options => 256 });

2. legacy_pm.epl
--------------
[.-
$app = shift @param;
eval "use perllib::${app}"; print $@ if $@;
use IO::Scalar;
$s = undef;
tie *OUT, 'IO::Scalar', \$s; # override OUT handle so that print statements
will go to $s
$SaveSTDOUT = select; # save current handle
select OUT; # set default handle so that "print" without a handle will
default to this
eval "${app}::main()"; print $@ if $@;
select $SaveSTDOUT; # restore original handle
$escmode = 0; #don't escape html tags (in $s)
-]
[+ $s +]
--------------

3. legacy.pm
- %IN = ();
if ($r->method eq "POST") {
%IN = $r->content;
} else {
%IN = $r->args;
}
-bunch of perl code with print statements which go to $s

__END__

All this works perfectly via GET.
When using POST, the request hangs at the $r->content point.

Why?

Any help or clues are appreciated.

Thank you.

ilia.
RE: help resolve complex mod_perl EPL framework [ In reply to ]
>
> All this works perfectly via GET.
> When using POST, the request hangs at the $r->content point.
>
> Why?
>

I guess your script has already read the POSTed data, before Execute is
called. Now Embperl, which can't know that the data is already read, tries
to read it again, and hangs, because all data is already read from STDIN.

Solution: Call Execute with

options => HTML::Embperl::optDisableFormData

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
-------------------------------------------------------------
RE: help resolve complex mod_perl EPL framework [ In reply to ]
> >
> > All this works perfectly via GET.
> > When using POST, the request hangs at the $r->content point.
> >
> > Why?
> >
>
> I guess your script has already read the POSTed data, before Execute is
> called. Now Embperl, which can't know that the data is already read, tries
> to read it again, and hangs, because all data is already read from STDIN.
>
> Solution: Call Execute with
>
> options => HTML::Embperl::optDisableFormData

But I am already using options => 256. Isn't it the same thing?

ilia.

>
> 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
> -------------------------------------------------------------
>
>
RE: help resolve complex mod_perl EPL framework [ In reply to ]
> >
> > options => HTML::Embperl::optDisableFormData
>
> But I am already using options => 256. Isn't it the same thing?
>

Yes it is, make sure that it really is set by inserting a

[+ $optDisableFormData +]

inside the called page. Should print 1. Does it?

Gerald
RE: help resolve complex mod_perl EPL framework [ In reply to ]
> > >
> > > options => HTML::Embperl::optDisableFormData
> >
> > But I am already using options => 256. Isn't it the same thing?
> >
>
> Yes it is, make sure that it really is set by inserting a
>
> [+ $optDisableFormData +]
>
> inside the called page. Should print 1. Does it?

Yes it does print 1. Problem still stands. :(

ilia.

>
> Gerald
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
RE: help resolve complex mod_perl EPL framework [ In reply to ]
>
> Yes it does print 1. Problem still stands. :(
>

You could try to set $ENV{CONTENT_LENGTH} = 0 ; before the call to Execute,
but this really shouldn't be nessecary.

Maybe there is another call that tries to read the POSTed data a second
time?

Gerald
RE: help resolve complex mod_perl EPL framework [ In reply to ]
Ok I have another question. Why doesn't <<SetEnv EMBPERL_ESCMODE 0>> work?

It's supposed to set the default to 0, but it's still 3.

Please help.
RE: help resolve complex mod_perl EPL framework [ In reply to ]
>
> Ok I have another question. Why doesn't <<SetEnv EMBPERL_ESCMODE 0>> work?
>
> It's supposed to set the default to 0, but it's still 3.
>

It does set it to zero, but only when you use the mod_perl handler and not
if you call Execute on your own. If you call Execute on your own, you need
to call the ScanEnvironement before.

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
-------------------------------------------------------------
RE: help resolve complex mod_perl EPL framework [ In reply to ]
Dear Gerald,

Still no luck... However, now $optDisableFormData is 0, even though I have
options => 256 (also tried options => HTML::Embperl::optDisableFormData).

I am lost here...

Let me describe my process better:
1. Get form data using CGI_Lite into %IN
2. Pass fdat => \%IN and options => HTML::Embperl::optDisableFormData to
Execute an epl...
3. epl overrides default handle (OUT) to \$s. At this point,
$optDisableFormData is 0. epl calls pm...
4. pm prints html
5. epl outputs [+ $s +]

All works fine with GET.

arghhh... pulling hair... hopes it's a bug in Embperl...

ilia.


> -----Original Message-----
> From: Gerald Richter [mailto:richter@ecos.de]
> Sent: Wednesday, April 26, 2000 3:49 PM
> To: Ilia Lobsanov; embperl@perl.apache.org
> Subject: RE: help resolve complex mod_perl EPL framework
>
>
> >
> > Yes it does print 1. Problem still stands. :(
> >
>
> You could try to set $ENV{CONTENT_LENGTH} = 0 ; before the call
> to Execute,
> but this really shouldn't be nessecary.
>
> Maybe there is another call that tries to read the POSTed data a second
> time?
>
> Gerald
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
RE: help resolve complex mod_perl EPL framework [ In reply to ]
sorry, forgot one more thing in step 4... pm reads $r->content or $r->args.
The former fails.

ilia.

> -----Original Message-----
> From: Ilia Lobsanov [mailto:ilia@lobsanov.com]
> Sent: Wednesday, May 03, 2000 11:55 AM
> To: Gerald Richter; embperl@perl.apache.org
> Subject: RE: help resolve complex mod_perl EPL framework
>
>
> Dear Gerald,
>
> Still no luck... However, now $optDisableFormData is 0, even though I have
> options => 256 (also tried options => HTML::Embperl::optDisableFormData).
>
> I am lost here...
>
> Let me describe my process better:
> 1. Get form data using CGI_Lite into %IN
> 2. Pass fdat => \%IN and options => HTML::Embperl::optDisableFormData to
> Execute an epl...
> 3. epl overrides default handle (OUT) to \$s. At this point,
> $optDisableFormData is 0. epl calls pm...
> 4. pm prints html
> 5. epl outputs [+ $s +]
>
> All works fine with GET.
>
> arghhh... pulling hair... hopes it's a bug in Embperl...
>
> ilia.
>
>
> > -----Original Message-----
> > From: Gerald Richter [mailto:richter@ecos.de]
> > Sent: Wednesday, April 26, 2000 3:49 PM
> > To: Ilia Lobsanov; embperl@perl.apache.org
> > Subject: RE: help resolve complex mod_perl EPL framework
> >
> >
> > >
> > > Yes it does print 1. Problem still stands. :(
> > >
> >
> > You could try to set $ENV{CONTENT_LENGTH} = 0 ; before the call
> > to Execute,
> > but this really shouldn't be nessecary.
> >
> > Maybe there is another call that tries to read the POSTed data a second
> > time?
> >
> > Gerald
> >
> >
> > ---------------------------------------------------------------------
> > 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: help resolve complex mod_perl EPL framework [ In reply to ]
>
> sorry, forgot one more thing in step 4... pm reads $r->content or
> $r->args.
> The former fails.
>

And that's your error! CGI_lite has already read the form data, you cannot
read it again with $r -> content ($r -> content tries to read the form data
from stdin, where CGI_lite has them already read from). You need to pass the
formdata from CGI_lite to your module, and doen't reread them!

No bug in Embperl :-)

Gerald


> ilia.
>
> > -----Original Message-----
> > From: Ilia Lobsanov [mailto:ilia@lobsanov.com]
> > Sent: Wednesday, May 03, 2000 11:55 AM
> > To: Gerald Richter; embperl@perl.apache.org
> > Subject: RE: help resolve complex mod_perl EPL framework
> >
> >
> > Dear Gerald,
> >
> > Still no luck... However, now $optDisableFormData is 0, even
> though I have
> > options => 256 (also tried options =>
> HTML::Embperl::optDisableFormData).
> >
> > I am lost here...
> >
> > Let me describe my process better:
> > 1. Get form data using CGI_Lite into %IN
> > 2. Pass fdat => \%IN and options => HTML::Embperl::optDisableFormData to
> > Execute an epl...
> > 3. epl overrides default handle (OUT) to \$s. At this point,
> > $optDisableFormData is 0. epl calls pm...
> > 4. pm prints html
> > 5. epl outputs [+ $s +]
> >
> > All works fine with GET.
> >
> > arghhh... pulling hair... hopes it's a bug in Embperl...
> >
> > ilia.
> >
> >
> > > -----Original Message-----
> > > From: Gerald Richter [mailto:richter@ecos.de]
> > > Sent: Wednesday, April 26, 2000 3:49 PM
> > > To: Ilia Lobsanov; embperl@perl.apache.org
> > > Subject: RE: help resolve complex mod_perl EPL framework
> > >
> > >
> > > >
> > > > Yes it does print 1. Problem still stands. :(
> > > >
> > >
> > > You could try to set $ENV{CONTENT_LENGTH} = 0 ; before the call
> > > to Execute,
> > > but this really shouldn't be nessecary.
> > >
> > > Maybe there is another call that tries to read the POSTed
> data a second
> > > time?
> > >
> > > Gerald
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
RE: help resolve complex mod_perl EPL framework [ In reply to ]
I see... the problem is that I don't want to modify the pm ($r->content
etc)... there are many of them. The whole point of me doing all this
backwards is to make as little changes as possible to the legacy pm's.
Is it possible to somehow refill STDIN...?

thank you.

ilia.

> -----Original Message-----
> From: Gerald Richter [mailto:richter@ecos.de]
> Sent: Wednesday, May 03, 2000 1:25 PM
> To: Ilia Lobsanov; embperl@perl.apache.org
> Subject: RE: help resolve complex mod_perl EPL framework
>
>
> >
> > sorry, forgot one more thing in step 4... pm reads $r->content or
> > $r->args.
> > The former fails.
> >
>
> And that's your error! CGI_lite has already read the form data, you cannot
> read it again with $r -> content ($r -> content tries to read the
> form data
> from stdin, where CGI_lite has them already read from). You need
> to pass the
> formdata from CGI_lite to your module, and doen't reread them!
>
> No bug in Embperl :-)
>
> Gerald
>
>
> > ilia.
> >
> > > -----Original Message-----
> > > From: Ilia Lobsanov [mailto:ilia@lobsanov.com]
> > > Sent: Wednesday, May 03, 2000 11:55 AM
> > > To: Gerald Richter; embperl@perl.apache.org
> > > Subject: RE: help resolve complex mod_perl EPL framework
> > >
> > >
> > > Dear Gerald,
> > >
> > > Still no luck... However, now $optDisableFormData is 0, even
> > though I have
> > > options => 256 (also tried options =>
> > HTML::Embperl::optDisableFormData).
> > >
> > > I am lost here...
> > >
> > > Let me describe my process better:
> > > 1. Get form data using CGI_Lite into %IN
> > > 2. Pass fdat => \%IN and options =>
> HTML::Embperl::optDisableFormData to
> > > Execute an epl...
> > > 3. epl overrides default handle (OUT) to \$s. At this point,
> > > $optDisableFormData is 0. epl calls pm...
> > > 4. pm prints html
> > > 5. epl outputs [+ $s +]
> > >
> > > All works fine with GET.
> > >
> > > arghhh... pulling hair... hopes it's a bug in Embperl...
> > >
> > > ilia.
> > >
> > >
> > > > -----Original Message-----
> > > > From: Gerald Richter [mailto:richter@ecos.de]
> > > > Sent: Wednesday, April 26, 2000 3:49 PM
> > > > To: Ilia Lobsanov; embperl@perl.apache.org
> > > > Subject: RE: help resolve complex mod_perl EPL framework
> > > >
> > > >
> > > > >
> > > > > Yes it does print 1. Problem still stands. :(
> > > > >
> > > >
> > > > You could try to set $ENV{CONTENT_LENGTH} = 0 ; before the call
> > > > to Execute,
> > > > but this really shouldn't be nessecary.
> > > >
> > > > Maybe there is another call that tries to read the POSTed
> > data a second
> > > > time?
> > > >
> > > > Gerald
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > 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
> > >
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> >
> >
>
>
RE: help resolve complex mod_perl EPL framework [ In reply to ]
>
> I see... the problem is that I don't want to modify the pm ($r->content
> etc)... there are many of them. The whole point of me doing all this
> backwards is to make as little changes as possible to the legacy pm's.
> Is it possible to somehow refill STDIN...?
>

No, you can't refill stdin. You can take the form data and put them into
$r -> args, then must must belive your module that it has to take the form
data from args instead of content

Gerald


> thank you.
>
> ilia.
>
> > -----Original Message-----
> > From: Gerald Richter [mailto:richter@ecos.de]
> > Sent: Wednesday, May 03, 2000 1:25 PM
> > To: Ilia Lobsanov; embperl@perl.apache.org
> > Subject: RE: help resolve complex mod_perl EPL framework
> >
> >
> > >
> > > sorry, forgot one more thing in step 4... pm reads $r->content or
> > > $r->args.
> > > The former fails.
> > >
> >
> > And that's your error! CGI_lite has already read the form data,
> you cannot
> > read it again with $r -> content ($r -> content tries to read the
> > form data
> > from stdin, where CGI_lite has them already read from). You need
> > to pass the
> > formdata from CGI_lite to your module, and doen't reread them!
> >
> > No bug in Embperl :-)
> >
> > Gerald
> >
> >
> > > ilia.
> > >
> > > > -----Original Message-----
> > > > From: Ilia Lobsanov [mailto:ilia@lobsanov.com]
> > > > Sent: Wednesday, May 03, 2000 11:55 AM
> > > > To: Gerald Richter; embperl@perl.apache.org
> > > > Subject: RE: help resolve complex mod_perl EPL framework
> > > >
> > > >
> > > > Dear Gerald,
> > > >
> > > > Still no luck... However, now $optDisableFormData is 0, even
> > > though I have
> > > > options => 256 (also tried options =>
> > > HTML::Embperl::optDisableFormData).
> > > >
> > > > I am lost here...
> > > >
> > > > Let me describe my process better:
> > > > 1. Get form data using CGI_Lite into %IN
> > > > 2. Pass fdat => \%IN and options =>
> > HTML::Embperl::optDisableFormData to
> > > > Execute an epl...
> > > > 3. epl overrides default handle (OUT) to \$s. At this point,
> > > > $optDisableFormData is 0. epl calls pm...
> > > > 4. pm prints html
> > > > 5. epl outputs [+ $s +]
> > > >
> > > > All works fine with GET.
> > > >
> > > > arghhh... pulling hair... hopes it's a bug in Embperl...
> > > >
> > > > ilia.
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Gerald Richter [mailto:richter@ecos.de]
> > > > > Sent: Wednesday, April 26, 2000 3:49 PM
> > > > > To: Ilia Lobsanov; embperl@perl.apache.org
> > > > > Subject: RE: help resolve complex mod_perl EPL framework
> > > > >
> > > > >
> > > > > >
> > > > > > Yes it does print 1. Problem still stands. :(
> > > > > >
> > > > >
> > > > > You could try to set $ENV{CONTENT_LENGTH} = 0 ; before the call
> > > > > to Execute,
> > > > > but this really shouldn't be nessecary.
> > > > >
> > > > > Maybe there is another call that tries to read the POSTed
> > > data a second
> > > > > time?
> > > > >
> > > > > Gerald
> > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > 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
> > > >
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > > For additional commands, e-mail: embperl-help@perl.apache.org
> > >
> > >
> >
> >
>
>