http://www.perlmonks.org?node_id=861325

dwm042 has asked for the wisdom of the Perl Monks concerning the following question:

Easiest clean way to demonstrate the issue.

1. Install ubuntu server 10.04 or similar Debian based distro.

1a. sudo apt-get update ; sudo apt-get upgrade

2. Install catalyst

3. catalyst.pl testFileModel

4. Check to see that the development server works. Start with -r option.

5. Go to this site, which has a neat little Text File model.

6. Start adding content as per the article.

7. Once you add lib/testFileModel/Model/File.pm, check the debug output on the dev server. You will see this:

require testFileModel::Model::File was successful but the package is n +ot defined. at /usr/share/perl5/Catalyst/Utils.pm line 287. [debug] Debug messages enabled [debug] Statistics enabled [debug] Loaded plugins:

And at this point, as a beginner, I'm stuck. I wrote the author of the article, who has been pleasant and responsive, but his first suggestion was that the code was not in place. And not to pick on this particular model, but I've had this problem before, when I tried to use Catalyst::Model::Adaptor and add a non Catalyst Moose Class to a Catalyst project, getting the exact same error as above.

So I'm missing something, something simple, and I'm worried that #catalyst on irc.perl.org is as hostile to newb questions as #perl is reputed to be (I did see dhoss there, but he's asleep presently).

Questions that occur to me:

1. What can lead to that kind of error?

2. This config: how do I know that it works? If I built a Moose Class with one scalar, one array ref and one hash ref (that's it), applied Catalyst::Model::Adaptor and tried to populate the model with the configuration file, how do I know that it worked? Any easy way to confirm or test that?

Noob questions to be sure. But the tutorials leave out these kinds of issues.

I'd like to know how to get a model to "attach" to the Catalyst framework. And I'd like to know if it has been configured correctly, once attached.

Thanks for any help provided.

David.

Replies are listed 'Best First'.
Re: Catalyst Question: setting up new models in Catalyst
by Corion (Patriarch) on Sep 22, 2010 at 17:58 UTC

    You haven't shown any code, which makes it quite hard for us to guess what might have gone wrong in your elaborate and complicated setup.

    My wild guess is that you did not edit the "Test File Model" file testFileModel/Model/File.pm, so its first line still reads:

    package MyApp::Model::File;

    ... which will install all code into the MyApp::Model::File namespace and not into the testFileMode::Model::File namespace, which then seem s to confuse Catalyst.