[Catalyst] auto re-load of application yaml config file?

2008-07-22 Thread Marc Sebastian Pelzer

Hello,

I'm running a Catalyst application under mod_perl and wonder if there  
is a Plugin available that detects changes on the main  
application .yml config file and does a automatic re-load if needed?  
It not - what would be the most elegant (and less I/O intensive) way  
of doing this? Would it be enough to do a


__PACKAGE__->config( 'Plugin::ConfigLoader' => { file =>  
'my_config.yml' } );
in my Root controller when I detect a change? Also, is there a way to  
store the state (maybe the mtime of the config file) in memory without  
being lost between requests? Or do I need to store the mtime in a  
database/memcache/tempfile (which would be "expensive")?

Many thanks in advance for any hint :)


___
List: Catalyst@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/


Re: [Catalyst] Re: Private Chained Actions?

2008-07-05 Thread Marc Sebastian Pelzer

Hola,

to catch up with this topic, I'd like to mention that using moose  
seems to eat some extra CPU cycles. I'm not sure how good this  
performs in a high-load situation. So I'm going to stick with the $c- 
>forward('hello_setup'); way. Nevertheless, it would be great if,  
some day, chained private actions would be implemented within the  
appropriate chain-module.


Thanks, Marc



* Jonathan Rockway <[EMAIL PROTECTED]> [2008-06-20 22:20]:

  sub hello_setup : Private {
my ($self, $c) = @_
$c->stash->{setup} = 'done';
  }

  sub hello : Private {
my ($self, $c) = @_
$c->forward('hello_setup'); # <-
$c->res->body('hello! setup is ' . $c->stash->{setup});
  }

  sub index : Path : Args(0) {
my ($self, $c) = @_
$c->detach('hello');
  }


Yeah, that's ugly.  What you really want are method modifiers:

   package MyApp::Controller::Foo;
   use Moose;
   BEGIN { extends 'Catalyst::Controller' };

   sub main_page :Path Args(0) {
   my ($self, $c) = @_;
   $self->hello($c);
   }

   sub hello {
   my ($self, $c) = @_;
   $c->res->body('hello! setup is'. $c->stash->{setup});
   }

   before hello => sub {
   my ($self, $c) = @_;
   $c->stash->{setup} = 'done';
   };

   1;


That’s even uglier. Imagine there isn’t just `hello` but half a
dozen other methods all sharing the same setup. So the setup code
is one or two screens down the source file. Now when you look at
`hello` you have absolutely no indication whatsoever that there
might be other code running before it. The only sane way to do
this would go something like this:

   package MyApp::Controller::Foo;
   use Moose;
   BEGIN { extends 'Catalyst::Controller' };

   sub main_page :Path Args(0) {
   my ($self, $c) = @_;
   $self->hello($c);
   }

   sub hello_setup {
   my ($self, $c) = @_;
   $c->stash->{setup} = 'done';
   }

   before hello => \&hello_setup;
   sub hello {
   my ($self, $c) = @_;
   $c->res->body('hello! setup is'. $c->stash->{setup});
   }

   1;

By naming the setup method you can also avoid having to apply
the modifier to all of the methods at once.

Note that using method modifiers instead of Cat dispatch means
that the Catalyst::Stats breakdown of a request will be coarser.



___
List: Catalyst@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/


Re: [Catalyst] Re: Private Chained Actions?

2008-06-20 Thread Marc Sebastian Pelzer



You need a screwdriver, not a hammer.


   sub hello_setup : Private {
 my ($self, $c) = @_
 $c->stash->{setup} = 'done';
   }

   sub hello : Private {
 my ($self, $c) = @_
 $c->forward('hello_setup'); # <-
 $c->res->body('hello! setup is ' . $c->stash->{setup});
   }

   sub index : Path : Args(0) {
 my ($self, $c) = @_
 $c->detach('hello');
   }



thanks for the hint. Thats what I'm doing right now. I thought that  
there may be a more elegant way of doing this. Especially for a longer/ 
more complex chained setup :) Also, doing it this way it does not look  
not too nice in the dispatcher path in the debug logfile - hello()  
comes before hello_setup() :-|


Thanks! Marc


___
List: Catalyst@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/


[Catalyst] Private Chained Actions?

2008-06-20 Thread Marc Sebastian Pelzer

Hello,

I'd like to forward and/or detach to private actions which should be  
chained together, like:


sub hello_setup : Privat Chained {
  my ($self, $c) = @_

  $c->stash->{setup} = 'done';
}

sub hello : Private Chained('hello_setup') {
  my ($self, $c) = @_

  $c->res->body('hello! setup is ' . $c->stash->{setup});
}

sub index : Path : Args(0) {
  my ($self, $c) = @_

  $c->detach('hello');
}

This does actually not work. Only hello() is being called.

Has anyone an idea, how to make this work? Or is this just not  
supported (yet)?


Thanks, Marc :)

___
List: Catalyst@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/