Re: passing an object to a handler
On Wednesday, October 2, 2002, at 09:48 PM, Dave Rolsky wrote: > On Wed, 2 Oct 2002, william ross wrote: > >> I did have it set up that way at one point. it worked quite nicely as >> long as I made the singleton in a subclass of the main Factory (which >> might be shared by several applications with different >> configurations). >> i gave up on it in the end because it seemed a bit overheated, but if >> you approve, i shall reconsider. > > I'm not quite following you. Overheated? sorry. i just meant that it seemed like a lot of engineering - much of which was a little beyond me, though I've caught up a bit since - for what seemed like such a simple requirement. but i've just been doing as you suggested, and it does work rather nicely. thanks. >> so, rehearsing: all it should take is a Factory::Subclass->new(config >> blah) in the startup script and a Factory::Subclass->instance() in the >> handler? it does sound good if you put it like that. (dimwit: both calls should be to instance(). oops) >> incidentally I made the singleton like this (yes, more poop): >> >> use base qw (Class::DBI::Factory Class::Singleton); >> ... >> sub _new_instance { shift->new(@_) } >> >> but it felt rather naughty to subclass the private _new_instance. if >> anyone knows a better way, I'd be very glad to hear it. > > Check out Class::Singleton. er, that's what I said. guess it must be ok :) will
Re: passing an object to a handler
On Wednesday, October 2, 2002, at 09:11 PM, Dave Rolsky wrote: > On Wed, 2 Oct 2002, william ross wrote: > >> sorry: i wasn't very clear, was I? I am using a method handler, but I >> want to pass an object of another class to it each time it is called. >> The object needs to be created outside of an individual request, and >> therefore presumably in a startup file, and then either passed to the >> handler along with each request, or somehow made available to all the >> requests, but preferably without setting a class variable, which is >> what I do at the moment but dislike. > > You could make the other object a singleton, so you could just do: > > my $factory = My::Factory->instance I did have it set up that way at one point. it worked quite nicely as long as I made the singleton in a subclass of the main Factory (which might be shared by several applications with different configurations). i gave up on it in the end because it seemed a bit overheated, but if you approve, i shall reconsider. so, rehearsing: all it should take is a Factory::Subclass->new(config blah) in the startup script and a Factory::Subclass->instance() in the handler? it does sound good if you put it like that. incidentally I made the singleton like this (yes, more poop): use base qw (Class::DBI::Factory Class::Singleton); ... sub _new_instance { shift->new(@_) } but it felt rather naughty to subclass the private _new_instance. if anyone knows a better way, I'd be very glad to hear it. (but this is galloping quickly away from the topic, and I'm sure I can work it out in the end :) thank you. will
Re: passing an object to a handler
On Wednesday, October 2, 2002, at 08:37 PM, Per Einar Ellefsen wrote: > At 21:30 02.10.2002, william ross wrote: > >> On Wednesday, October 2, 2002, at 08:18 PM, Per Einar Ellefsen wrote: >> >>> At 20:47 02.10.2002, william ross wrote: >>>> but I can't find anything to tell me how to do it. I feel sure I'm >>>> missing something really obvious here? >>> >>> You can configure objects instead of using static class names. See >>> the doc: >>> >>> http://perl.apache.org/docs/1.0/guide/method_handlers.html >> >> sorry: i wasn't very clear, was I? I am using a method handler, but I >> want to pass an object of another class to it each time it is called. >> The object needs to be created outside of an individual request, and >> therefore presumably in a startup file, and then either passed to the >> handler along with each request, or somehow made available to all the >> requests, but preferably without setting a class variable, which is >> what I do at the moment but dislike. > > Yes, and that it exactly what the doc I referred to shows you: > You instantiate an object in your startup file; then you configure > mod_perl to call your handler with this object as the class, like: > PerlHandler $My::obj->handler > $My::Obj must then be an instance of the handler class, but can > contain any other information too. > Now, in your handler, you get: > sub handler ($$) { > my ($obj, $r) = @_; > > and you have your $obj, which you can use freely. ($obj isn't a class > name, it is an ... object!) > > Wasn't that what you wanted? no, not quite, though i begin to suspect that i wanted the wrong thing, and what you suggest - which I had read several times but apparently not taken in - is what I should be looking for. the trouble is that I want to have many handler objects - they hold session information, among other reasons - but I want each one to use the same factory object. I don't want to instantiate a single handler, as i think your snippet would. so i thought i'd make a new one each time and pass the factory to each one. but it looks - from what you say - like I've just got it back to front: at the moment Class::DBI::Handler expects to be given a Class::DBI::Factory object, but what I should do is put the handler($$) method in the factory itself, and construct a new Class::DBI::Factory::Handler object each time it's called, to hold whatever per-request information is required. excuse me thinking out loud: maybe you could warn me if it sounds like i've found another wrong tree. meanwhile, I'll go try it. thanks for your help will
Re: passing an object to a handler
On Wednesday, October 2, 2002, at 08:18 PM, Per Einar Ellefsen wrote: > At 20:47 02.10.2002, william ross wrote: >> but I can't find anything to tell me how to do it. I feel sure I'm >> missing something really obvious here? > > You can configure objects instead of using static class names. See the > doc: > > http://perl.apache.org/docs/1.0/guide/method_handlers.html sorry: i wasn't very clear, was I? I am using a method handler, but I want to pass an object of another class to it each time it is called. The object needs to be created outside of an individual request, and therefore presumably in a startup file, and then either passed to the handler along with each request, or somehow made available to all the requests, but preferably without setting a class variable, which is what I do at the moment but dislike. thanks will
passing an object to a handler
hello, I've been off-list for a while, so please forgive (and direct) me if this is a tired subject. In short, i'd like to pass through another object on method invocation, in addition to the apache request. Ideally the (method)handler would look something like: sub handler ($$$) { my ($class, $r, $factory) = @_; ... } where $factory is an object I made earlier, and is shared among all the requests. I'd like to avoid class data because the handler will almost always be subclassed, and anyway it makes me nervous. And for the same reason I don't want to make the factory a singleton: each single, hard-working object of the factory class will have a different configuration. but I can't find anything to tell me how to do it. I feel sure I'm missing something really obvious here? thanks will
Re: [challenge] new mod_perl site - [OT]
same here, also on 10.1. I got past that one by forcing the got_storable sub to return 0, just out of curiosity, and was rewarded with complaints about the absence of Pod::POM::View::HTML. which is certainly absent. i imagine that a lot of the people you would most like to respond to your challenge are using OS X... will At 9:06 pm +0100 16/11/01, allan wrote: >hello > >does anyone know what to do with this problem, which happens >to me on Macintosh os X 10.1: > > >[localhost:/Applications/modperl-site-new] aju% bin/build -vf ># >### HTML DocSet: Home ### ># >+++ Reading cache from >/Applications/modperl-site-new/bin/../src/cache.html.dat >Byte order is not compatible at blib/lib/Storable.pm >(autosplit into blib/lib/auto/Storable/_retrieve.al) line 311, >at /Library/Perl/DocSet/Cache.pm line 37 >[localhost:/Applications/modperl-site-new] aju% > > > > >i have no problem with this: >[localhost:/Applications/DocSet/example] aju% bin/build -vf > > >thanks >allan
Re: [challenge] new mod_perl site
At 10:44 am -0800 14/11/01, Nick Tonkin wrote: >No one doubts your commitment to mod_perl, or your hard -- and unpaid >-- work on the guide and many other things. But if you want to be a leader >who inspires people to collaborate and work as a team under your >direction, you'd do well to work on bringing your people skills up to par >with your technical skills, IMHO. uh oh. having just read this: http://www.geocrawler.com/lists/3/SourceForge/4/125/7038861/ I'm feeling rather nervous about silly insults directed at the leaders of open-source projects on which my livelihood depends. brickbats are the price of celebrity,i suppose, but i really don't think this one is justified at all. best will ps. i found the [challenge] quite persuasive, and the restrictions just a clear and sensible brief. but then i'm shallow and seek glory.