[Catalyst] Re: Handy shotcuts

J. Shirley jshirley at gmail.com
Thu Mar 20 15:53:36 GMT 2008


On Thu, Mar 20, 2008 at 8:36 AM, Matt Lawrence <matt.lawrence at ymogen.net> wrote:
> J. Shirley wrote:
>  > On Thu, Mar 20, 2008 at 7:05 AM, Michele Beltrame <mb at cattlegrid.info> wrote:
>  >
>  >> Hi Aristotle!
>  >>
>  >>
>  >>  > But `uri_for` can take a lot more parameters than just one;
>  >>  > there's no reason you have to restrict your utility methods
>  >>  > to the first one.
>  >>
>  >>  Also, it would be handy to be able to pass the status parameter (i.e.
>  >>  303 is widely used) to res->redirect() when using these utlity methods
>  >>  as well.
>  >>
>  >>  Michele.
>  >>
>  >>  --
>  >>  Michele Beltrame
>  >>  http://www.cattlegrid.info/
>  >>  ICQ 76660101 - MSN mb at italpro.net
>  >>
>  >>
>  >>
>  >>  _______________________________________________
>  >>  List: Catalyst at lists.scsys.co.uk
>  >>  Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>  >>  Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>  >>  Dev site: http://dev.catalyst.perl.org/
>  >>
>  >>
>  >
>  > It seems more reasonable to have a slightly more intelligent utility method.
>  >
>  > Something that sets the status to 303 if the request type is a post
>  > (and HTTP 1.1 as Aristotle posted earlier, although I'm not sure what
>  > the "best" way to check is.  Assume it is unless stated otherwise, or
>  > vice-versa?)
>  >
>  >
>  That makes sense for deciding whether or not to use 303, but deciding
>  whether a redirection should be 301, 302 or 307 is not so deterministic.
>
>  Would it be evil to treat any initial /^3\d\d$/ argument as a status?
>
>  It would be cleaner, but less concise, to use a hash-like configuration:
>
>  # Temporary redirect to /my/action/1/2/3?q=search%20string
>  $c->uri_redirect({
>     action => '/my/action',
>     args => [qw( 1 2 3 )],
>     status => 307,
>     query => { q => "search string" },
>     # detach => 1 ??
>  });
>
>  It should also be possible to support both syntaxes at once.
>
>  Matt
>
>
>

I still think it makes more sense as a controller action rather than a
$c-> method.

At the prod of zby (thanks), I've written up my approach in the wiki
at http://catwiki.toeat.com/gettingstarted/tutorialsandhowtos/Redirect_Methods

I suggest others do the same?  I highly doubt there will be a
universal utility method added to core, but the core devs will speak
to that.  It just seems too opinionated of a feature to really exist
peacefully in core.

-J

-- 
J. Shirley :: jshirley at gmail.com :: Killing two stones with one bird...
http://www.toeat.com



More information about the Catalyst mailing list