This is a discussion on Re: Fwd: MPM-safe mp2 Singleton Pattern? - modperl ; Am Freitag, 7. November 2008 19:22:56 schrieb Steven Siebert: > Perfect! Great info from both...exactly what I needed. After > Torsten's response, I theorized that I could abstract that > functionality up and reveal a thin API for the creation/calling ...
Am Freitag, 7. November 2008 19:22:56 schrieb Steven Siebert:
> Perfect! Great info from both...exactly what I needed. After
> Torsten's response, I theorized that I could abstract that
> functionality up and reveal a thin API for the creation/calling of
> singleton objects within a namespace in pnotes....but that seems to
> have already been done with Apache::Singleton::Request. I'm glad I
> decided to ask the experts before attempting a hack myself. Thanks
> On Fri, Nov 7, 2008 at 1:18 PM, bharanee rathna
> >> The simplest way is to put the object as a pnote:
> > What Torsten said, but have a look at
> > http://search.cpan.org/~miyagawa/Apa...Apache/Singlet
> > Apache::Singleton::Request is probably what you want.
I couldn't get Apache::Singleton working with mp2 (used it before with no
problems with mp1). so I switched back to Class::Singelton and, at the top of
my handler (MasonX::WebApp) destroy the old instance and create a new one. I
couldn' t find ouy why it failed with mp2 since I had not much time and my
app had to become ready. The failure showed in a "hanging" request.
The reason why I use Class::Singelton (and not $r->pool or $r->pnotes) is
just, that I can reuse my perl modules in all apps running as stand alone
scripts. So for instance , I put my DBIx;:Class schema object in there, the
logging handler etc.