[Catalyst] Organizing link generators

Alexander Hartmaier alexander.hartmaier at t-systems.at
Thu Nov 11 08:01:17 GMT 2010


I strongly advise to use $c->controller('Auth')->action_for('edit')
instead of '/auth/company/lot/vin/edit' to not let Catalyst guess what
you mean.
The string can fail if you have a typo in it and will be hard to spot.

--
Best regards, Alex


On Sat, 2010-10-23 at 18:57 +0200, Eden Cardim wrote:
> >>>>> "Evan" == Evan Carroll <me at evancarroll.com> writes:
>
>     Evan> My view often needs to generate complex links for chained
>     Evan> actions.  Does anyone have a better way of doing this then
>     Evan> recreating the link generators in the controller?
>
> $c->stash->{generate_link_edit} = sub {
>   my $vin = shift;
>   $c->uri_for_action(
>       '/auth/company/lot/vin/edit'
>       , [
>         $c->stash->{chained_company_id}
>         , $c->stash->{chained_lot_id}
>         , $vin
>       ]
>       , ()
>   );
> };
>
> $c->stash->{generate_link_vehicle_add} = sub {
>   $c->uri_for_action(
>       '/auth/company/lot/inventory/add'
>       , [
>         $c->stash->{chained_company_id}
>         , $c->stash->{chained_lot_id}
>       ]
>       , ()
>   );
> };
>
> You should weaken the $c since that code will leak memory without
> it. And yes, that's currently the best way to generate urls (that I can
> think of anyway), although you can save some typing by using hash slices
> instead.
>


*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
T-Systems Austria GesmbH   Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*
Notice: This e-mail contains information that is confidential and may be privileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*



More information about the Catalyst mailing list