[Catalyst-dev] Proposal for new module: Catalyst::Plugin::Memory

Simon Bertrang janus at errornet.de
Wed Oct 8 16:55:49 BST 2008


On Wed, Oct 08, 2008 at 08:28:39AM -0500, Peter Karman wrote:
> Simon Bertrang wrote on 10/08/2008 07:28 AM:
> > Hi,
> > i need a way to save various kinds of information between different
> > points in the request chain.
> > Initially i abused the stash for this, but polluting the template with
> > data not needed there or even worse, preventing things to work as
> > expected, did not work out.
> > The session would have been another solution but the same arguments
> > apply there as for the templates.
> > 
> > What was left:
> >  a) accessing $c manually to hand over the data
> >  b) implement a controller providing a common method
> >  c) writing a plugin
> > 
> 
> what about (d) ?
> 
> package MyApp;
> 
> sub mystuff {
>  my ($c, %newstuff) = @_;
>  my $stuff = $c->stash->{_my_stuff};
>  $stuff->{$_} = $newstuff{$_} for keys %newstuff;
>  return $stuff;
> }
> 
> I find just having a reserved stash key for things I want to pass around
> but not necessarily pollute my template with works pretty well.

Well, then i could delete that thing out of stash in end, yes.  But i'm
more in favor of having it not in the stash in the first place.

Thanks for the suggestion though :-)

Regards,
Simon



More information about the Catalyst-dev mailing list