FAQ
I want to be able to setup a configuration variable in my Catalyst config
that will then be set as the value for one of my model's class variables.
I have a model that will want to use a base path to store some files, However
the Model doesn't know how to access Catalyst and so it can't get the data it
needs. The other issue is that I need it as a class variable so that all of
the instances of a particular class can access the same value once set. I'm
thinking about calling an after method in the root Catalyst app module to set
the variable, but I'm not sure which one I should modify.

Anybody with some suggestions?

--
o) Derek Wueppelmann (o
(D . dwueppel@gmail.com D).
((` http://www.monkeynet.ca ( ) `

Search Discussions

  • David Schmidt at Mar 28, 2011 at 5:00 pm

    On Mon, Mar 28, 2011 at 6:49 PM, Derek Wueppelmann wrote:
    I want to be able to setup a configuration variable in my Catalyst config
    that will then be set as the value for one of my model's class variables.
    I have a model that will want to use a base path to store some files, However
    the Model doesn't know how to access Catalyst and so it can't get the data it
    needs. The other issue is that I need it as a class variable so that all of
    the instances of a particular class can access the same value once set. I'm
    thinking about calling an after method in the root Catalyst app module to set
    the variable, but I'm not sure which one I should modify.

    Anybody with some suggestions?

    --
    ?o) ? Derek Wueppelmann ? ? ? ? ? (o
    (D . ? dwueppel@gmail.com ? ? ? ? ?D).
    ((` ? ? http://www.monkeynet.ca ? ( ) `


    _______________________________________________
    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/
    Usually that's achieved by adding an attribute to your model and then
    providing the value at model instantiation time

    Example:
    http://wiki.catalystframework.org/wiki/wikicookbook/configpass2schema
  • Eden Cardim at Apr 11, 2011 at 7:37 pm
    "David" == David Schmidt writes:
    David> Usually that's achieved by adding an attribute to your model and then
    David> providing the value at model instantiation time

    --8<---------------cut here---------------start------------->8---
    MyApp->config->{Model::Foo}{bar} = 'baz';

    package MyApp::Model::Foo;
    has bar => (is => 'ro');
    --8<---------------cut here---------------end--------------->8---

    The above should set the bar attribute during load time for you straight
    out of the box.

    --
    Eden Cardim Need help with your Catalyst or DBIx::Class project?
    Code Monkey http://www.shadowcat.co.uk/catalyst/
    Shadowcat Systems Ltd. Want a managed development or deployment platform?
    http://blog.edencardim.com/ http://www.shadowcat.co.uk/servers/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedMar 28, '11 at 4:49p
activeApr 11, '11 at 7:37p
posts3
users3
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2021 Grokbase