[Catalyst-dev] Proposal for new module: Catalyst::Plugin::Memory
Matt S Trout
dbix-class at trout.me.uk
Wed Oct 8 15:56:08 BST 2008
On Wed, Oct 08, 2008 at 02:28:02PM +0200, Simon Bertrang wrote:
> 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.
Catalyst::Component::InstancePerContext sticks stuff in the stash as well,
it just picks fairly careful key names and I've never had a clash.
Basically, this is what the stash is -for-, and introducing a second thing
that means the same thing only under a different name would be wrong.
I think what you maybe want is to override template_args or whatever relevant
method in your view so that it uses %{$c->stash->{template_info}} instead of
just %{$c->stash} ?
Alternatively, Template Toolkit refuses to expose keys starting with an _
for just this purpose, so if you do
$c->stash->{_internal}{foo} = ...
then you're absolutely safe from the template accessing it.
The other thing you could do, of course, is if the data is per-controller
then use Catalyst::Component::InstancePerContext in your controllers and
then do
$self->foo($foo);
and further down $c->controller('Whatever')->foo
Thoughts on these different approaches?
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst-dev
mailing list