[Catalyst] Sanity Check -- requesting feedback on chaining approach
    will trillich 
    will.trillich at serensoft.com
       
    Wed Feb 16 02:14:25 GMT 2011
    
    
  
Catalystas -- this chaining stuff is wicked awesome. We've been following
the below paradigm for the most part, and now we want to expand a bit:
package MyApp::Controller::Xyzzy;
sub base     : Chained         PathPart('xyzzy') CaptureArgs(0) {  }
  sub list   : Chained('base') PathPart('')             Args(0) {  }
  sub item   : Chained('base') PathPart('')      CaptureArgs(1) {  }
    sub view : Chained('item') PathPart('')             Args(0) {  }
The two new nodes we want to insert are for csv-download (delivering all
records) and paging (delivering a subset). Here's what we're thinking:
package MyApp::Controller::Xyzzy;
sub base     : Chained         PathPart('xyzzy') CaptureArgs(0) {  }
  sub list   : Chained('base') PathPart('')      *Capture*Args(0) {  }
*    sub page : Chained('list') PathPart('')             Args(0) {  }
    sub csv  : Chained('list') PathPart('csv')          Args(0) {  }
*  sub item   : Chained('base') PathPart('')      CaptureArgs(1) {  }
    sub view : Chained('item') PathPart('')             Args(0) {  }
Here the index view would come from *page*() instead of directly from *list=
*().
*csv*() would download resultset->search->({%params})->all whereas *page*()
would resultset->search({%params},{page=3D>$p,rows=3D>$r}).
So any search parameters would be handled inside list() and then paging
parameters would be handled separately inside page(). Right? Is there an
elegant way to separate the two sets of parameters?
Does this seem like a "best practice"? Comments welcome.
-- =
The first step towards getting somewhere is to decide that you are not going
to stay where you are.  -- J.P.Morgan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110215/c8bd4=
b23/attachment.htm
    
    
More information about the Catalyst
mailing list