X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;h=5a91f46a92299f68f6de8ece7cba7333b465d217;hb=c0f74851f0f37dd24be65f03ad29f71fb642db99;hp=59b30c29a6a0f9893471da78a00b3d0683be662f;hpb=9d17368e8d5a29c37d3a98332da6a00976643a49;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 59b30c2..5a91f46 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -21,7 +21,8 @@ use Scalar::Util qw/weaken/; use Tree::Simple qw/use_weak_refs/; use Tree::Simple::Visitor::FindByUID; use attributes; -use YAML (); +use YAML::Syck; +use File::Slurp; __PACKAGE__->mk_accessors( qw/counter request response state action stack namespace/ @@ -48,7 +49,7 @@ our $DETACH = "catalyst_detach\n"; require Module::Pluggable::Fast; # Helper script generation -our $CATALYST_SCRIPT_GEN = 25; +our $CATALYST_SCRIPT_GEN = 26; __PACKAGE__->mk_classdata($_) for qw/components arguments dispatcher engine log dispatcher_class @@ -59,7 +60,7 @@ __PACKAGE__->engine_class('Catalyst::Engine::CGI'); __PACKAGE__->request_class('Catalyst::Request'); __PACKAGE__->response_class('Catalyst::Response'); -our $VERSION = '5.62'; +our $VERSION = '5.64'; sub import { my ( $class, @arguments ) = @_; @@ -246,7 +247,10 @@ in an arrayref. The action will receive the arguments in C<@_> and C<$c-Ereq-Eargs>. Upon returning from the function, C<$c-Ereq-Eargs> will be restored to the previous values. - $c->forward('/foo'); +Any data Ced from the action forwarded to, will be returned by the +call to forward. + + my $foodata = $c->forward('/foo'); $c->forward('index'); $c->forward(qw/MyApp::Model::CDBI::Foo do_stuff/); $c->forward('MyApp::View::TT'); @@ -445,7 +449,7 @@ Returns or takes a hashref containing the application's configuration. __PACKAGE__->config({ db => 'dsn:SQLite:foo.db' }); -You can also use a L config file like myapp.yml in your +You can also use a L config file like myapp.json in your applications home directory. --- @@ -471,10 +475,16 @@ L. =head2 $c->log -Returns the logging object instance. Unless it is already set, Catalyst -sets this up with a L object. To use your own log class: +Returns the logging object instance. Unless it is already set, Catalyst sets +this up with a L object. To use your own log class, set the +logger with the C<< __PACKAGE__->log >> method prior to calling +C<< __PACKAGE__->setup >>. + + __PACKAGE__->log( MyLogger->new ); + __PACKAGE__->setup; + +And later: - $c->log( MyLogger->new ); $c->log->info( 'Now logging with my own logger!' ); Your log class should implement the methods described in the @@ -586,7 +596,10 @@ sub setup { || $class->path_to( ( Catalyst::Utils::appprefix( ref $class || $class ) . '.yml' ) ); my $conf = {}; - $conf = YAML::LoadFile($confpath) if -f $confpath; + if ( -f $confpath ) { + my $content = read_file("$confpath"); + $conf = YAML::Syck::Load($content); + } my $oldconf = $class->config; $class->config( { %$oldconf, %$conf } ); @@ -821,6 +834,7 @@ sub welcome_message {

If you want to jump right into web development with Catalyst you might want to check out the documentation.

perldoc Catalyst::Manual::Intro
+perldoc Catalyst::Manual::Tutorial
 perldoc Catalyst::Manual

What to do next?

Next it's time to write an actual application. Use the @@ -917,7 +931,7 @@ via $c->error. sub execute { my ( $c, $class, $code ) = @_; - $class = $c->components->{$class} || $class; + $class = $c->component($class) || $class; $c->state(0); if ( $c->debug ) { @@ -937,14 +951,14 @@ sub execute { # this is done by walking up the call stack and looking for a calling # sub of Catalyst::forward before the eval my $callsub = q{}; - for my $index (1..10) { - last - if ( ( caller($index) )[0] eq 'Catalyst' + for my $index ( 1 .. 10 ) { + last + if ( ( caller($index) )[0] eq 'Catalyst' && ( caller($index) )[3] eq '(eval)' ); - - if ( (caller($index))[3] =~ /forward$/ ) { - $callsub = (caller($index))[3]; - $action = "-> $action"; + + if ( ( caller($index) )[3] =~ /forward$/ ) { + $callsub = ( caller($index) )[3]; + $action = "-> $action"; last; } }