i knew autohandlers would be suggested at some point, but they won't work for what i'm trying to do. the component wrapper is intended to to be called multiple times on a page. i'm not trying to reinvent autohandlers although this kinda behaves like a mini-dynamic-autohandler.
also, the wrapper could be calling components from many different locations (our code base is 5+ years old and is huge). with all this, you can see the challenge in doing this functionality in an autohandler, and more to the point, autohandlers are really the wrong way to do it. as an interim solution i have used the following as a work around in the wrapper: $m->comp( { content => sub { return $m->content } }, 'name.mas' ); but then you start getting to abstract but it works for now. -- William Cox email: [EMAIL PROTECTED] blog: http://my-dimension.com/ music: http://www.last.fm/user/mydimension/ photos: http://flickr.com/photos/mydimension/ On 1/30/07, Oliver Jeeves <[EMAIL PROTECTED]> wrote: > William Cox wrote: > > i'm trying to do something funky here so i'll do my best to explain. i > > have the component which is meant to dynamically wrap other widgets in > > order to centrally handle caching, access control, etc... > > > > ideally it should be as transparent as possible and this includes > > calling components with content. however because the content is passed > > to this wrapper and not the target component this presents a bit of a > > problem. what i would like is to re-pass that content on down into the > > target component. Example: > > > > top_component.mas > > ================ > > <h1>Hello World!</h1> > > <&| 'wrapper.mas', component => 'name.mas' &> > > <% $ARGS{name} %> > > </&> > > > > wrapper.mas > > ========== > > <%init> > > $m->comp( { content => $m->content }, 'name.mas' ); > > </%init> > > > > name.mas > > ======== > > <p>Good to meet you <% $m->content %></p> > > > > > > This is an extremely simplified example of what i'm actually doing. > > but you can see the problem in that the content effectively gets > > executed twice. i'd like to call something like $m->content_ref that > > can be used in the wrapper.mas so that when $m->content is called in > > the target component it is calling exactly what was passed from the > > parent component. > > > > thanks for your help. > > > > Before offering any advice, it might be a good idea for you to try and > explain your motivation for doing this a bit more. I suspect that there > are other, easier ways to do what you want. > > For example, authorization can be handled in an autohandler with: > > <%init> > if (user_has_access) > { > $m->call_next; > } > else > { > $m->comp('/components/login.mas'); # or an error document > } > </%init> > > Where 'user_has_access' can involve calling some central function or > component. > > Alternativly, you could put this in your root autohandler (so that you > have no duplicated code) with something like this: > > <%init> > unless ($m->user->has_access( $m->base_comp->attr('require') ) > { > $m->redirect('/', 301); # or whatever action you want to take > } > > # ... > > $m->call_next; > > </%init> > > Where each component would have an <%attr> block specifying the required > access: > > <%attr> > require => 'admin' > </%attr> > > Regards, > Oliver. > > > > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users