[Catalyst] How to make chained actions nice?

Robert 'phaylon' Sedlacek rs at 474.at
Mon Apr 9 11:22:27 GMT 2007


Danny Warren wrote:

> # Responds to /object/list
> sub list : Local { ... }
> 
> # Captures object id, as in /object/[OBJ_ID]
> sub object : PathPart('object') Chained CaptureArgs(1) { ... }
> 
> # Responds to /object/[OBJ_ID]/edit
> sub edit : Chained('object') Args(0) { ... }
> 
> # Chain point for chaining to property controller
> # NOTE: This is just a jump point, don't put bizlogic in here,
> #       put it in the property controller
> sub property : Chained('object') CaptureArgs(0) { ... }

I usually handle this with a common base chain element:

sub base: Chained PathPart('object') CaptureArgs(0) { }
sub list: Chained('base') Args(0) { }          	# /list
sub load: Chained('base') CaptureArgs(1) { }
sub edit: Chained('load') Args(0)		# /object/23/edit
...

.phaylon



More information about the Catalyst mailing list