You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@perl.apache.org by "Bjarni R. Einarsson" <br...@klaki.net> on 2001/05/09 00:20:36 UTC

Patch for Apache::Registry to "solve" closure problems.

Hi,

I hope I'm sending this to the right list, and apologize in
advance if I'm making a mistake.  I have made a minor modification
to the Apache::Registry.pm module, which I wanted to share with
the list in case you developers thought it was worth including in
the default distribution or considering further.

My code attempts to address the subroutine-closure problem (the
problem that causes data from one invocation to live on to the
next in many unmodified CGI scripts) by moving all subroutine
definitions, variable declarations (my, local) and use statements
out of handler() and into the generated packages' body.

Attached are a simple script which implements my algorithm (for
playing with) and a crude patch against Registry.pm (version 2.01)
which uses the algorithm.  Since I didn't know whether people
would like my code or not, I didn't spend time updating the
documentation section of the module.

Initial tests on my personal web site indicate that this patch
works quite well.

The main caveat about my algorithm is that since perl is hard to
parse, I wimped out and made assumptions about how programmers use
white space: I assume that people indent their subroutine bodies
by at least a single space or tab and close all subroutines with a
'}' in column 1.  Since this requirement might break some scripts,
my patch doesn't activate unless the comment #MASH_OK is found
somewhere within the script.

Any feedback is most welcome, but please CC: any followups to my
personal address (bre@klaki.net), since I'm not subscribed to this
list.  And thanks for mod_perl. :-)

-- 
Bjarni R. Einarsson                           PGP: 02764305, B7A3AB89
 bre@klaki.net                -><-              http://bre.klaki.net/

Check out my open-source email sanitizer: http://mailtools.anomy.net/

Re: Patch for Apache::Registry to "solve" closure problems.

Posted by Doug MacEachern <do...@covalent.net>.
On Fri, 11 May 2001, Bjarni R. Einarsson wrote:

> On 2001-05-10, 20:02:00 (-0700), Doug MacEachern wrote:
> > 
> > thanks for the patch!  however, Apache::Registry no longer accepts new
> > features.  have you looked at Apache::{PerlRun,RegistryNG} ?
> 
> No I hadn't - but now I have.  Much nicer code - why hasn't it replaced
> Apache::Registry?  Is there any reason I shouldn't run it on my server?

it hasn't replaced it simply because we wanted more people to test it and
the interface is still subject to change.
it probably won't replace Apache::Registry in 1.xx, but there will be
something like it for 2.0.
 
> Ok, attached is my proposition for "Apache::RegistryPretty", which
> is an improvement over Apache::Registry as long as the input code is
> "pretty".  :-)  I subclassed Apache::RegistryNG and wrote a 
> replacement for the sub_wrap routine (modifying readscript wouldn't
> have worked).
> 
> This time I documented it.  If you like the code, would you please
> take care of submitting it to "the right place" for me, since I 
> haven't a clue about CPAN submission rules?

i have not reviewed it closely yet, you might want to post to the main
modperl@apache.org list where i'm sure some people will be interested in
trying it out.
info on registering/submitting to cpan is here:
 http://www.cpan.org/scripts/submitting.html



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


Re: Patch for Apache::Registry to "solve" closure problems.

Posted by "Bjarni R. Einarsson" <br...@klaki.net>.
On 2001-05-10, 20:02:00 (-0700), Doug MacEachern wrote:
> 
> thanks for the patch!  however, Apache::Registry no longer accepts new
> features.  have you looked at Apache::{PerlRun,RegistryNG} ?

No I hadn't - but now I have.  Much nicer code - why hasn't it replaced
Apache::Registry?  Is there any reason I shouldn't run it on my server?

> you would just need to create a new subclass that overrides the
> 'readscript' method and modifies it according to your algorithm.
> if you get that going would be great to post here and/or cpan.

Ok, attached is my proposition for "Apache::RegistryPretty", which
is an improvement over Apache::Registry as long as the input code is
"pretty".  :-)  I subclassed Apache::RegistryNG and wrote a 
replacement for the sub_wrap routine (modifying readscript wouldn't
have worked).

This time I documented it.  If you like the code, would you please
take care of submitting it to "the right place" for me, since I 
haven't a clue about CPAN submission rules?

Thanks!

-- 
Bjarni R. Einarsson                           PGP: 02764305, B7A3AB89
 bre@klaki.net                -><-              http://bre.klaki.net/

Check out my open-source email sanitizer: http://mailtools.anomy.net/

Re: Patch for Apache::Registry to "solve" closure problems.

Posted by Doug MacEachern <do...@covalent.net>.
On Tue, 8 May 2001, Bjarni R. Einarsson wrote:

> Hi,
> 
> I hope I'm sending this to the right list, and apologize in
> advance if I'm making a mistake.  I have made a minor modification
> to the Apache::Registry.pm module, which I wanted to share with
> the list in case you developers thought it was worth including in
> the default distribution or considering further.
> 
> My code attempts to address the subroutine-closure problem (the
> problem that causes data from one invocation to live on to the
> next in many unmodified CGI scripts) by moving all subroutine
> definitions, variable declarations (my, local) and use statements
> out of handler() and into the generated packages' body.
> 
> Attached are a simple script which implements my algorithm (for
> playing with) and a crude patch against Registry.pm (version 2.01)
> which uses the algorithm.  Since I didn't know whether people
> would like my code or not, I didn't spend time updating the
> documentation section of the module.

thanks for the patch!  however, Apache::Registry no longer accepts new
features.  have you looked at Apache::{PerlRun,RegistryNG} ?
you would just need to create a new subclass that overrides the
'readscript' method and modifies it according to your algorithm.
if you get that going would be great to post here and/or cpan.



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