Is there anything wrong with using this in autohandler <%once> our ($my_cute_app); </%once>
<%init> $my_cute_app = My::Cute::App->new(); </%init> then using $my_cute_app in all components called by the autohandler ? Then you can have not only shared data, but also shared methods etc. I am mostly a mason noob (use it rarely for personal projects), but that seems the most mason-ic solution :) Emil On Dec 16, 2007 12:42 AM, Xicheng Jia <[EMAIL PROTECTED]> wrote: > On 12/14/07, Anthony Ettinger <[EMAIL PROTECTED]> wrote: > > Can you perhaps provide a link to details about this technique? which > > files, how it gets instantiated, etc. > > > > I definitely want the "global" to be instantiated on each request, > > without sharing value between users. and then dies off at the end of > > the request. > > I think $m->notes() just did all what you want. It lives per-request, > so different users have different $m->notes, you can use $m->notes to > deliver information between Mason components, and use > $HTML::Mason::Commands::m->notes(....) to get/set notes information in > the backend Perl modules. So no need to reinvent the wheel.. > > If you use "global", i.e. $stash as defined in Jonathan's post, I > think you can just localize it in your top-most autohandler to keep > its values per-request: > > <%init> > local $stash; > .... > </%init> > > But to differentiate it between users, you need to make $stash a hash > reference keyed by session-ids or any unique-ids. you probably still > need $m->notes to deliver these ids between components or backend > modules.... or just use $m->session or the like instead of the global > $stash.. Just my $0.02. > > Regards, > Xicheng > > > > On Dec 14, 2007 4:52 PM, Jonathan Swartz <[EMAIL PROTECTED]> wrote: > > > If all you want is a global stash (as in TT), then you could create a > > > global called $stash visible to all components: > > > > > > allow_globals => [qw($stash)] > > > ... > > > $interp->set_global(stash => { ... }); > > > > > > This is no different than > > > > > > package HTML::Mason::Commands; > > > use vars qw($stash); > > > > > > $HTML::Mason::Commands::stash = { ... }; > > > > > > > > > > > > On Dec 14, 2007, at 3:48 PM, Anthony Ettinger wrote: > > > > > > > On Dec 14, 2007 1:45 PM, Perrin Harkins <[EMAIL PROTECTED]> wrote: > > > >> On Dec 14, 2007 3:04 PM, Steven Saner <[EMAIL PROTECTED]> wrote: > > > >>> Don't you have a reference to the MasonX::WebApp object defined as a > > > >>> global variable, $app or whatever? You could store the data in that > > > >>> object. > > > >> > > > >> Is there any advantage you know of to using something like > > > >> $app->data() over $m->notes()? > > > >> > > > >> - Perrin > > > >> > > > > > > > > > > > > Is $app->data() something that's available as a standard? > > > > > > > > I use $m->notes() for this sort of stuff, but the problem I have is > > > > its only available to mason parts (not backend perl modules that are > > > > loaded). > > > > > > > > -- > > > > Anthony Ettinger > > > > 408-656-2473 > > > > http://anthony.ettinger.name > > > > > > > > var (bonita, farley) = new Dog; > > > > farley.barks("very loud"); > > > > bonita.barks("at strangers"); > > > > > > > > ---------------------------------------------------------------------- > > > > > > > --- > > > > SF.Net email is sponsored by: > > > > Check out the new SourceForge.net Marketplace. > > > > It's the best place to buy or sell services > > > > for just about anything Open Source. > > > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/ > > > > marketplace > > > > _______________________________________________ > > > > Mason-users mailing list > > > > Mason-users@lists.sourceforge.net > > > > https://lists.sourceforge.net/lists/listinfo/mason-users > > > > > > > > > > > > > > > > > > -- > > Anthony Ettinger > > 408-656-2473 > > http://anthony.ettinger.name > > > > var (bonita, farley) = new Dog; > > farley.barks("very loud"); > > bonita.barks("at strangers"); > > > > ------------------------------------------------------------------------- > > SF.Net email is sponsored by: > > Check out the new SourceForge.net Marketplace. > > It's the best place to buy or sell services > > for just about anything Open Source. > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > > _______________________________________________ > > Mason-users mailing list > > Mason-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/mason-users > > > -- > Xicheng Jia (Ph.D in Comp. Applied Math) > > ------------------------------------------------------------------------- > > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services > for just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Mason-users mailing list > Mason-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/mason-users > ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users