X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst.pm;h=00e62faa7590cafa889b9543da282d21e9e1d49f;hp=179c7ac3e0b81b7af0aec8c343e82f4be8985759;hb=df912746b14abdadf70ae982f4b79ab459f08377;hpb=9e7673af3a03f61edd17142d1ebfd415119e48be diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 179c7ac..00e62fa 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 JSON; +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,11 +449,12 @@ 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. - --- - db: dsn:SQLite:foo.db + { + "db": "dsn:SQLite:foo.db" + } =head2 $c->debug @@ -587,12 +592,15 @@ sub setup { $class->setup_home( delete $flags->{home} ); - # YAML config support + # JSON config support my $confpath = $class->config->{file} || $class->path_to( - ( Catalyst::Utils::appprefix( ref $class || $class ) . '.yml' ) ); + ( Catalyst::Utils::appprefix( ref $class || $class ) . '.json' ) ); my $conf = {}; - $conf = YAML::LoadFile($confpath) if -f $confpath; + if ( -f $confpath ) { + my $content = read_file("$confpath"); + $conf = jsonToObj($content); + } my $oldconf = $class->config; $class->config( { %$oldconf, %$conf } ); @@ -827,6 +835,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 @@ -923,7 +932,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 ) {