Weitere ähnliche Inhalte Ähnlich wie Practical catalyst (20) Kürzlich hochgeladen (20) Practical catalyst2. In the beginning there was HTML <a href=”http://www.cnn.com”>CNN</a> And it was good. But it didn't change.. 3. HTML was a response to the “ Tower of Babel” problem. Computers had trouble talking in ways that were independent of the operating systems and applications on which they were based. HTML and browsers were a way around that. 4. CGI – dynamic HTML With forms and content that users could interact with, the tools were built to give us things like ecommerce, web mail, etc. 33. “Definitive Guide to Catalyst” recommends vendor Perl plus local::lib plus per user CPAN install. 35. Starting a Project catalyst.pl ProjectName This creates a directory structure just off your home dir. 37. A Typical Controller Method sub intro : Local { my ( $self, $c ) = @_; my $params = $c->req->params; $c->stash( current_view => 'TT' ); $c->stash( template => 'draft/intro.tt' ); } 53. Flash: longer term. Used often with the flash_to_stash config set. Useful for storage when handling forms. 54. Session: lasts some time. Can last longer than visitor's login, 2 hrs by default. Don't use same data names as stash, because they interact. 66. You might want to export row hashes if you're working with JSON views (broken with objects). 68. ResultSet returning AoH sub position_array { my ( $self, $sport_id ) = @_; my @rows = $self->search( sport_id => $sport_id, { order_by => { -asc => 'id'}} ); my @positions; for (@rows) { my %row = $_->get_columns; push @positions, row; } return positions; } 77. Advantage is the model can be tested and used outside of Catalyst (cmd line apps). 78. Typical Ajax request via jQuery function savesession() { clearstatus(); clearerror(); var lhcoll=$("#sortable").sortable("serialize"); var rhcoll=$("#sortable2").sortable("serialize"); var data = {}; data.ajax = 1; data.savesession = 1; data.lhcoll = lhcoll; data.rhcoll = rhcoll; jQuery.post("[% c.uri_for( c.controller.action_for('topplayer')) -%]", data, function ( hash ) { addstatus( hash.status_msg ); }, 'json' ); }; 79. Catalyst Ajax dispatching my %tp_dispatch = ( savesession => 'do_save_tpl', clearsession => 'do_clear_tpl', save_db_session => 'do_save_db_tpl', load_db_session => 'do_load_db_tpl', ); # code code code if ( $params->{ajax} ) { for ( keys %tp_dispatch ) { $c->forward( $tp_dispatch{$_} ) if ( $params->{$_} ); } } 80. Output to a view (composite) if ( $params->{ajax} ) { $c->stash( current_view => 'JSON' ); } else { $c->stash( lh => $lists->{lh} ); $c->stash( rh => $lists->{rh} ); $c->stash( current_view => 'TT' ); $c->stash( template => 'draft/topplayer.tt' ); } 84. Because of the transition of Cat to Moose, some changes to instantiation are required now. 92. Often asked to provide some functions, but not all, that would normally be handled by root. 98. This leads to the idea of using web interfaces as automation components