Any takers?
Dave?
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gareth
Kirwan
Sent: 22 December 2006 12:07
To: mason-users@lists.sourceforge.net
Subject: [Mason] chain_append feature
I've got a situation where my dhandler comps an action:
/items/10/view
/items/10 decides to call a component 'view'.
In my autohandlers throughout I want to be able to call methods and
attributes on this component.
I could store it in a global, or do something else with it, but that didn't
seem fitting.
I wanted to do:
$m->request_comp->scall_method('title') and the such like.
Not only this, but I wanted dhandler to stay in the chain, since I feel it's
fitting.
The chain should look like:
/autohandler -> /items/autohandler -> /items/dhandler -> /items/view
This obviously shouldn't be arbitrary. dhandlers call many components, and
rarely want to do exactly this.
It should be something that is decided by the dhandler itself:
$m->chain_append( $m->fetch_comp( $action ) );
$m->call_next( item_id => $id );
It should be down to the dhandler to protect $action, or the literal,
against !$m->comp_exists.
I couldn't find anything like this in Mason currently, so I did it manually.
sub chain_append {
my ($self, $next) = @_;
if ($next && !ref $next){
return unless $self->comp_exists($next);
$next = $self->fetch_comp($next);
}
return unless $next;
my ($current_index) = sort {$b<=>$a} values
%{$self->{wrapping_index}};
$self->{wrapper_index}->{$next->comp_id} = ++$current_index;
push @{$self->{wrapper_chain}}, $next;
$self->{request_comp} = $next;
return $self;
}
This works perfectly for me.
Two questions:
1) Is there something I've missed that makes the whole concept invalid?
2) I feel that this should be part of mason, rather than a plugin. Do others
agree?
Merry Christmas, everyone.
Gareth Kirwan
Programming & Development,
Thermeon Europe Ltd,
[EMAIL PROTECTED]
Tel: +44 (0) 1293 864 303
Thermeon Europe e-Card: gbjk <http://www.thermeoneurope.com/e-Card/gbjk>
-------------------------------------------------------------------------
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