[Catalyst] Catalyst global object
Marcus Ramberg
marcus at thefeed.no
Wed Jul 13 10:38:25 CEST 2005
luke saunders skrev:
> My application is called Holiday, the skeleton of which was created
> with the create.pl script. It uses the controller Page and CDBI::Sweet
> for the DB stuff. In Holiday.pm I create a new Handler object which is
> needed for the Holiday system to work properly. Now I need this
> Handler object to be available globally (to the controller and models)
> and therefore it would be ideal if I could put it in the catalyst
> Context object somewhere as that's available everywhere. Is there
> anywhere I can put it in the Context object? If not how could I make
> this Handler object available to the objects instantiated by Catalyst?
Hey Luke.
Why don't you just put it in the stash?
$c->stash->{handler} = MyHandler->new(); in begin or whatnot?
then it'll be available from all your classes as $c->stash->{handler},
and just handler in your templates. you say you need this available in
models as well. Models usually don't have access to context, but you can
use the Catalyst::Plugin::Singleton to get a context from anywhere.
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: marcus.vcf
Type: text/x-vcard
Size: 282 bytes
Desc: not available
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20050713/f89e6fe6/marcus.vcf
More information about the Catalyst
mailing list