[Catalyst] Re: Handy shotcuts
Matt Lawrence
matt.lawrence at ymogen.net
Thu Mar 20 15:36:45 GMT 2008
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
More information about the Catalyst
mailing list