mp 1 bug with method handlers and internal redirects
Hi, I'm trying to figure out if anything ever happened with this bug where internal redirects cause method handlers to get called as subs. http://marc.info/?l=apache-modperl-devm=101261915419106w=2 http://marc.info/?l=apache-modperlm=106839932418976w=2 The thread ends without a fix and I don't see anything in 1.30 that looks like a fix. Any ideas? - Perrin
Re: method handlers
Jordan McLain wrote: just noticed... in the actual code 'handler' is prototyped with ($$) sub handler { my ($class, $r) = @_; my $self = ... # something hashref-ish I will end up writing another new() for use when not called directly from apache. Is this bad style, since the method does not return the blessed ref to something, but instead calls methods directly with the blessed ref? Personally I get Apache to call new() for me, so other code can use the class in the same way apache does: --- in httpd.conf: PerlModule My::HandlerModule PerlResponseHandler My::HandlerModule-handler_method # apache calls your new() method automatically I think PerlFixupHandler My::HandlerModule-fixup_handler_method --- Or even better, when I want a single instance of my handler module per apache process: --- package My::HandlerModule; $My::HandlerModule::Persistent=My::HandlerModule-new(); sub new { etc etc } sub handler_method { my ($self,$r)[EMAIL PROTECTED]; etc etc } --- in httpd.conf: PerlResponseHandler $My::HandlerModule::Persistent-handler_method --- hope this helps, John
Re: Re: method handlers
Ahh, I see. Great tip. Thanks alot. Jordan On 10/27/06, John ORourke [EMAIL PROTECTED] wrote: Jordan McLain wrote: just noticed... in the actual code 'handler' is prototyped with ($$) sub handler { my ($class, $r) = @_; my $self = ... # something hashref-ish I will end up writing another new() for use when not called directly from apache. Is this bad style, since the method does not return the blessed ref to something, but instead calls methods directly with the blessed ref? Personally I get Apache to call new() for me, so other code can use the class in the same way apache does: --- in httpd.conf: PerlModule My::HandlerModule PerlResponseHandler My::HandlerModule-handler_method # apache calls your new() method automatically I think PerlFixupHandler My::HandlerModule-fixup_handler_method --- Or even better, when I want a single instance of my handler module per apache process: --- package My::HandlerModule; $My::HandlerModule::Persistent=My::HandlerModule-new(); sub new { etc etc } sub handler_method { my ($self,$r)[EMAIL PROTECTED]; etc etc } --- in httpd.conf: PerlResponseHandler $My::HandlerModule::Persistent-handler_method --- hope this helps, John
method handlers
Hello, This is more of a style and usage question. Sorry for the stupid question. I am rewriting one of my apps to be more OO so that I can abstract its' functionality out to another handler potentially. I end up doing something like this... sub handler { my ($class, $r) = @_; my $self = ... # something hashref-ish bless $self, $class; ... my $method = $modes{$mode}; # hash lookup of available modes $self-$method; return OK; } I will end up writing another new() for use when not called directly from apache. Is this bad style, since the method does not return the blessed ref to something, but instead calls methods directly with the blessed ref? thanks, Jordan Mclain eCarList.com
Re: method handlers
just noticed... in the actual code 'handler' is prototyped with ($$) On 10/26/06, Jordan McLain [EMAIL PROTECTED] wrote: Hello, This is more of a style and usage question. Sorry for the stupid question. I am rewriting one of my apps to be more OO so that I can abstract its' functionality out to another handler potentially. I end up doing something like this... sub handler { my ($class, $r) = @_; my $self = ... # something hashref-ish bless $self, $class; ... my $method = $modes{$mode}; # hash lookup of available modes $self-$method; return OK; } I will end up writing another new() for use when not called directly from apache. Is this bad style, since the method does not return the blessed ref to something, but instead calls methods directly with the blessed ref? thanks, Jordan Mclain eCarList.com
Re: [mp2] Method Handlers creating a new object vs ref
And I've never seen a situation where 'self was a ref' could you please enlighten me. the vast majority of the time $self is the class name, since you generally see this kind of config PerlResponseHandler My::Class-handler http://perl.apache.org/docs/1.0/guide/method_handlers.html#Simple_example lists an example like PerlHandler $My::Obj-method which doesn't look valid to me outside of a Perl section, but who knows. anyway, when I was doing the part on method handlers for the mod_perl cookbook I said $self is always the name of the class and IIRC stas pointed me to that example so I changed the wording to usually. but I've never seen it used in real life like that - certainly not by me. but maybe ask or someone else has :) --Geoff
Re: [mp2] Method Handlers creating a new object vs ref
Geoffrey Young wrote: anyway, when I was doing the part on method handlers for the mod_perl cookbook I said $self is always the name of the class and IIRC stas pointed me to that example so I changed the wording to usually. but I've never seen it used in real life like that - certainly not by me. but maybe ask or someone else has :) OK, one more mystery solved. On a sidenote, I've bought mod_perl cookbook, very nice to be talking to one of the people involved, your work is very much appreciated! --Geoff -- kind regards, Tim Esselens
Re: [OSCon 2005] rfc Inherited Method Handlers for mod_perl
Hopefully I can start spreading the word at OSCON. I'll submit this proposal tomorrow evening, provided no one has any additional suggestions. I gave a talk on object oriented mod_perl at apachecon us 2002 that you might (or might not) find helpful http://www.modperlcookbook.org/~geoff/slides/ApacheCon/2002/oo-mod_perl-printable.ppt.gz --Geoff
Re: [OSCon 2005] rfc Inherited Method Handlers for mod_perl
On Mon, 2005-02-07 at 20:20 -0600, Nicholas Studt wrote: Good point, that is poorly worded. I have been using this method for a couple of years now, but I don't know of any open source projects that are using this method. Krang (http://krang.sf.net/) uses them, although really just for organization rather than for actual inheritance. We used them for inheritance at eToys, which I described in the tutorial on perl.apache.org. I use them quite often in my own projects, especially when using CGI::Application for a controller, but I don't have any other handy open source examples. Maybe some others from here? http://perl.apache.org/products/app-server.html http://perl.apache.org/products/products.html - Perrin
Re: [OSCon 2005] rfc Inherited Method Handlers for mod_perl
Nicholas Studt wrote: I'm planning on submitting the following talk proposal for a 45 minute presentation session: Inherited method handlers for mod_perl [...] The only uncertainty I have right now is on on the last section of the talk. I don't know of any project currently using this method, though I have not looked too far. If you know of a project that does use an approach please let me know. The topic is certainly interesting, but I'm confused by the part where you say that you don't know who uses that technique. You mean you came up with that technique/practice w/o using it yourself? -- __ Stas BekmanJAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide --- http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [OSCon 2005] rfc Inherited Method Handlers for mod_perl
On Mon, 2005-02-07 at 19:50 -0500, Stas Bekman wrote: Nicholas Studt wrote: I'm planning on submitting the following talk proposal for a 45 minute presentation session: Inherited method handlers for mod_perl [...] The only uncertainty I have right now is on on the last section of the talk. I don't know of any project currently using this method, though I have not looked too far. If you know of a project that does use an approach please let me know. The topic is certainly interesting, but I'm confused by the part where you say that you don't know who uses that technique. You mean you came up with that technique/practice w/o using it yourself? Good point, that is poorly worded. I have been using this method for a couple of years now, but I don't know of any open source projects that are using this method. -- Nicholas Studt [EMAIL PROTECTED]
Re: [OSCon 2005] rfc Inherited Method Handlers for mod_perl
On Mon, 2005-02-07 at 21:37 -0500, Stas Bekman wrote: Nicholas Studt wrote: On Mon, 2005-02-07 at 19:50 -0500, Stas Bekman wrote: Nicholas Studt wrote: I'm planning on submitting the following talk proposal for a 45 minute presentation session: Inherited method handlers for mod_perl [...] The only uncertainty I have right now is on on the last section of the talk. I don't know of any project currently using this method, though I have not looked too far. If you know of a project that does use an approach please let me know. The topic is certainly interesting, but I'm confused by the part where you say that you don't know who uses that technique. You mean you came up with that technique/practice w/o using it yourself? Good point, that is poorly worded. I have been using this method for a couple of years now, but I don't know of any open source projects that are using this method. So that's your chance to spread the knowledge and then you will see other projects using it. One idea could be to write a tutorial for perl.apache.org, so the technique gets a better visibility. Then you could adopt that text for your presentation. Or vice versa. Whenever I write a tutorial or a presentation I merge that information at perl.apache.org docs and vice versa :) Hopefully I can start spreading the word at OSCON. I'll submit this proposal tomorrow evening, provided no one has any additional suggestions. -- Nicholas Studt [EMAIL PROTECTED]
[OSCon 2005] rfc Inherited Method Handlers for mod_perl
I'm planning on submitting the following talk proposal for a 45 minute presentation session: Inherited method handlers for mod_perl 1. What is an inherited handler and its benefits (5min) a) Single handler for all packages. b) Speeds code development. c) Removes repeated code. 2. A simple example (10min) a) How to inherit a handler into multiple packages. 3. Treating handlers completely like objects, a complex example. (10min) a) A single generalized handler. b) Overriding configuration methods. c) Putting it all together. 4. Multiply inherited handlers (10min) a) Customizing the handler for a specific application. 5. Who is doing this now. (5min) a) Projects that implement this idea * All examples will utilize mod_perl 2.0, though this idea can be used identically in mod_perl 1.x The only uncertainty I have right now is on on the last section of the talk. I don't know of any project currently using this method, though I have not looked too far. If you know of a project that does use an approach please let me know. -- Nicholas Studt [EMAIL PROTECTED]