Res: [Catalyst-dev] Catalyst tutorial

Carl Franks fireartist at gmail.com
Wed Sep 3 11:35:29 BST 2008


2008/9/3 Matt S Trout <dbix-class at trout.me.uk>:
> On Tue, Aug 26, 2008 at 10:26:05AM -0700, Daniel Nicoletti wrote:
>> also in the catalyst tutorial
>> there are tow problems one is that
>> is sugest the use of .conf (apache like)
>> instead of the yaml.
>
> That's not a problem. .conf is the new default and you'll find the FormFu
> docs are being steadily updated to help reflect that.

Well, I've changed HTML::FormFu::Manual::Unicode from using myapp.yml
to MyApp->config().
And I've changed the example config in Catalyst-Controller-HTML-FormFu
to use Config::General.

But I'm not sure about changing the core FormFu documentation to
Config::General.
It's probably because there's a lot less FormFu users, than Catalyst
has - but the OP in this thread is the only person I can ever recall
who's posted a message to the FormFu list with non-yaml config.
I think I'm going to have to see if the yaml is a genuine problem for
more users, before spending the time changing all the examples - which
at a rough count, could be over a thousand lines:

    $ find lib -name '*.pm' -exec perl -lni -e '$x=1 if /=head/; print
if $x' '{}' \;
    $ ack '^    ' lib | wc -l
    > 1270

It's also one thing to say "everyone that knows better still uses yaml
anyway" - but I suspect that most new people - of any ability - will
just use what's documented. And I'd really rather not have to support
Config::General rather than yaml - it's a lot more verbose, and it
doesn't support some features that I use in yaml, such as references
to repeated data, and multiple documents in a single file.

Matt - I do appreciate that I've no idea how often this comes up on
irc, and how much pain it may be causing you.
I've tried getting past my firewall by connecting to irc.perl.org with
an ssh-tunnel, but it immediately tries to bounce me to another server
- at which point it stops dead, because my ssh-tunnel can only see
irc.perl.org
If you/anyone knows a way around this, I *will* get back on irc more
regularly, and I'll get a #formfu channel started - which would at
least give you somewhere to punt people asking formfu questions on
#catalyst

In the meantime, I've been thinking of adding a quick script that can
be used at the command line, which uses Config::Any to load up a
config file, and dump the contents using Data::Dumper - to see if the
file's parsed as you expect.
This is the kind of thing I do quite often with a 1-liner, and so
should probably be available for anyone to use more easily.

>> Caught exception in MyApp::Controller::Books->formfu_create "Error parsing /home/daniel/code/catalyst/MyApp/root/forms/books/formfu_create.conf: Config::General: Cannot create hashref from <constraints> because there is
>> already a scalar option 'constraints' with value 'SingleValue'
>
> Config::General should handle that fine. Check you don't have an old version
> please?

I'm using the latest Config::General (2.40), and get the same error message.
It can't combine a scalar value and a hash-ref into a single value:

    constraints Required
    <constraints>
        type = SingleValue
    </constraints>

I advise that with Config::General, that you always use the hash-ref varient:

    <constraints>
        type = Required
    </constraints>
    <constraints>
        type = SingleValue
    </constraints>

Because if you use the scalar-value version, when you eventually want
to add a constraint that needs more than just the 'type' set, you'll
need to change all the other constraints to the hashref version,
anyway.

    constraint Required
    constraint Single
    # now can't add a constraint that needs any options set !

Carl



More information about the Catalyst-dev mailing list