FAQ
is there a way to have some C's and M's load into catalyst
conditionally? for example, if some config variable is set?

cheers

D

Search Discussions

  • Matt S Trout at Jul 16, 2007 at 2:18 pm

    On Mon, Jul 16, 2007 at 02:48:50PM +0200, Daniel McBrearty wrote:
    is there a way to have some C's and M's load into catalyst
    conditionally? for example, if some config variable is set?
    Exclude some of them with setup_components config.

    Or just do it via @INC manipulation - I use this a fair bit for testing.

    Depends what you're trying to achieve really, and you haven't told us :)

    --
    Matt S Trout Need help with your Catalyst or DBIx::Class project?
    Technical Director Want a managed development or deployment platform?
    Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
    http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
  • Christopher H. Laco at Jul 16, 2007 at 2:26 pm

    Matt S Trout wrote:
    On Mon, Jul 16, 2007 at 02:48:50PM +0200, Daniel McBrearty wrote:
    is there a way to have some C's and M's load into catalyst
    conditionally? for example, if some config variable is set?
    Exclude some of them with setup_components config.

    Or just do it via @INC manipulation - I use this a fair bit for testing.

    Depends what you're trying to achieve really, and you haven't told us :)
    Actually, this has me curious as well. In my case, I'd like to load
    "Setup" controllers only when someone passes a --setup arg...so they
    can use the web based config once, deliberately. After that, just
    loading the app wouldn't expose those controllers to the world accidentally.

    -=Chris

    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: signature.asc
    Type: application/pgp-signature
    Size: 187 bytes
    Desc: OpenPGP digital signature
    Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070716/fa202a14/signature.pgp
  • Jason Kohles at Jul 18, 2007 at 2:51 am

    On Jul 16, 2007, at 9:26 AM, Christopher H. Laco wrote:

    Matt S Trout wrote:
    On Mon, Jul 16, 2007 at 02:48:50PM +0200, Daniel McBrearty wrote:
    is there a way to have some C's and M's load into catalyst
    conditionally? for example, if some config variable is set?
    Exclude some of them with setup_components config.

    Or just do it via @INC manipulation - I use this a fair bit for
    testing.

    Depends what you're trying to achieve really, and you haven't told
    us :)
    Actually, this has me curious as well. In my case, I'd like to load
    "Setup" controllers only when someone passes a --setup arg...so they
    can use the web based config once, deliberately. After that, just
    loading the app wouldn't expose those controllers to the world
    accidentally.
    This is one technique that I've used for having controllers that are
    only enabled while in debug mode, seems simple enough to change the
    condition that disables it. Just put this in the controller class...

    sub register_actions {
    my ( $self, $c ) = @_;

    if ( ! $c->debug ) { return }
    return $self->SUPER::register_actions( $c );
    }

    --
    Jason Kohles
    email@jasonkohles.com
    http://www.jasonkohles.com/
    "A witty saying proves nothing." -- Voltaire
  • Daniel McBrearty at Jul 16, 2007 at 2:33 pm
    ok, I'll spill ... !

    I'll run one version of the site in "translate" mode - the "members"
    there are actually translators, they login and ... translate. Hence
    there is a model/controller that has all that stuff

    Of course I could just leave it in for the prod site, but I'd rather
    just have those components not load at all ...

    On 7/16/07, Matt S Trout wrote:
    On Mon, Jul 16, 2007 at 02:48:50PM +0200, Daniel McBrearty wrote:
    is there a way to have some C's and M's load into catalyst
    conditionally? for example, if some config variable is set?
    Exclude some of them with setup_components config.

    Or just do it via @INC manipulation - I use this a fair bit for testing.

    Depends what you're trying to achieve really, and you haven't told us :)

    --
    Matt S Trout Need help with your Catalyst or DBIx::Class project?
    Technical Director Want a managed development or deployment platform?
    Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
    http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/

    _______________________________________________
    List: Catalyst@lists.rawmode.org
    Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
    Dev site: http://dev.catalyst.perl.org/

    --
    Daniel McBrearty
    email : danielmcbrearty at gmail.com
    http://www.engoi.com
    http://danmcb.vox.com
    http://danmcb.blogger.com
    find me on linkedin and facebook
    BTW : 0873928131
  • Matt S Trout at Jul 16, 2007 at 5:00 pm

    On Mon, Jul 16, 2007 at 03:34:10PM +0200, Daniel McBrearty wrote:
    ok, I'll spill ... !

    I'll run one version of the site in "translate" mode - the "members"
    there are actually translators, they login and ... translate. Hence
    there is a model/controller that has all that stuff

    Of course I could just leave it in for the prod site, but I'd rather
    just have those components not load at all ...
    Plugin setup happens before component setup so you can supply exclude data
    from the config file then.

    --
    Matt S Trout Need help with your Catalyst or DBIx::Class project?
    Technical Director Want a managed development or deployment platform?
    Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
    http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
  • Mark Zealey at Jul 16, 2007 at 5:33 pm
    I use:

    package MyApp;
    use Catalyst qw/ ... /;

    my @extra_plugins;

    if( $ENV{CATALYST_DEBUG} ) {
    push @extra_plugins => qw/ Static::Simple StackTrace /;
    }

    # Start the application
    __PACKAGE__->setup( @extra_plugins );



    Mark
    On Monday 16 July 2007 1:48 pm, Daniel McBrearty wrote:
    is there a way to have some C's and M's load into catalyst
    conditionally? for example, if some config variable is set?

    cheers

    D

    _______________________________________________
    List: Catalyst@lists.rawmode.org
    Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
    Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
    Dev site: http://dev.catalyst.perl.org/
  • Kee Hinckley at Jul 17, 2007 at 2:14 am

    On Jul 16, 2007, at 8:48 AM, Daniel McBrearty wrote:

    is there a way to have some C's and M's load into catalyst
    conditionally? for example, if some config variable is set?
    You can call load_classes() and pass something other than the default
    values. At one point for some reason I wanted to load only the
    modules at the top of my Schema directory, and not include anything
    in subfolders, so I did this:

    throws ::Error::Unexpected;

    # Only get the first level items, I don't want sub folders.
    use Module::Find;
    __PACKAGE__->load_classes(map { substr $_, length(__PACKAGE__ .
    '::') } findsubmod(__PACKAGE__));

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedJul 16, '07 at 1:48p
activeJul 18, '07 at 2:51a
posts8
users6
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase