alfie has asked for the wisdom of the Perl Monks concerning the following question:


I faced a quite strange problem today: We are running a mason-powered site which is really a great thing. For I just started with mason just some weeks ago I first used <%method> to hand over some arguments from the component to the autohandler.

Now I found out about the usage of <%attr> and wanted to use that instead. To have a fallback through the transition I wanted to get the attr inside the method to hand it over. The problem is, a method is a subcomponent.

Now, how can I hand over the attr from the current component within a method without having to do such strange things like this:

<%method foo> % return $m->fetch_comp('')->attr('bar'); </%method>
As you might see this is quite annoying for I have to put the name of the current component into it. But if I use current_comp instead of fetch_comp I get the subcomponent (which is foo in this case), and if I use parent I get the autohandler, not the real component.

So - to put it simple: How can I get to the real component from a sub component? I have tried to dig through the docs at but haven't found anything useful - I guess I'm just blind and it might get worse after searching for several hours. So - any hint would be greatful!
use signature; signature(" So long\nAlfie");

Replies are listed 'Best First'.
Re: mason: how to get attr out of a subcomponent?
by blakem (Monsignor) on Aug 27, 2001 at 21:06 UTC
    This is from memory, but I think:
    will do the trick....


      Unfortunately, callers(1) gives me the same result like current_comp->parent. With value of 0 I get the current_comp, so this doesn't help at all.

      No one else an idea? Am I out of luck? Unfortunately the #mason on opn seems to be quite dead (it's empty after all) so I think I'll have to bug the mailing lists. Thanks anway for the try.
      use signature; signature(" So long\nAlfie");