[Dbix-class] Catalyst actions

Oleg Pronin syber.rus at gmail.com
Thu May 17 19:59:09 GMT 2007


Use

sub index : Private {
    #search code
}

And everything's gonna be ok


2007/5/17, Richard Jones <ra.jones at dpw.clara.co.uk>:
>
> Help - I'm going round in circles with Catalyst actions. I want
> http://localhost:3000/search to map to the method search() in
> MyApp::Controller::Search, so I defined the method as:
>
> sub search : Path Form('/search') { # a formbuilder method
> if ( $form->submitted && $form->validate ) {
>    $c->detach('retrieve');
> }
> # etc;
> }
>
> sub retrieve : Private {
> # performs db lookup, results in $rs, then:
>
> if (! $rs->pager->total_entries || $rs->pager->total_entries > 1000) {
>    $c->stash->{error_msg} =3D sprintf 'Total records matched =3D %s, plea=
se
> refine search', $rs->pager->total_entries;
>    $c->detach('search'); # re-load search form with message
> }
> else {
>    # display results in template
> }
> }
>
> Now, if the $rs->pager->total_entries value triggers
> $c->detach('search'), then the following error is generated:
>
> Couldn't render template "file error - search/search: not found"
>
> I also sometime see [% Catalyst.uri_for('search') %] translating to
> 'base_url/search/search' in the template, and though ugly, it does work.
>
> It's probably got something to do with the definition of search() as an
> empty Path, but that's the only way I could get the the address to read
> http://localhost:3000/search as opposed to something ugly like
> http://localhost:3000/search/search, as it does if I define search() as
> a Local action, ie 'sub search : Local'.
>
> I've also tried playing with calling the default method 'index' and
> 'default', and various attributes Local, Path, Global (I know that one's
> wrong) but ran into problems with all of those. I can't do a
> $c->res->redirect to the url '/search' as I need the original search
> params reloading. Can anyone see an obvious solution to this? Probably
> to do it the correct way!
>
> --
> Richard Jones
>
>
> _______________________________________________
> List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
> http://www.mail-archive.com/dbix-class@lists.rawmode.org/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20070517/2ce=
6edf7/attachment.htm


More information about the Dbix-class mailing list