[jifty-devel] Reusing Jifty models outside Jifty apps

Agent Zhang agentzh at gmail.com
Tue Dec 12 02:15:24 EST 2006


On 12/11/06, Jesse Vincent <jesse at bestpractical.com> wrote:
> > Actually I've tried this piece of code before taking the harder
> > approach. But I got the following error:
> >
> >    Can't locate Qooqle/Record.pm in @INC (@INC contains: lib
> > E:/Perl/lib E:/Perl/site/lib .) at lib/Qooqle/Model/QQUser.pm line 25.
> >    BEGIN failed--compilation aborted at lib/Qooqle/Model/QQUser.pm
> > line 25. Compilation failed in require at bin/qqimport.pl line 15.
> >    BEGIN failed--compilation aborted at bin/qqimport.pl line 15.
> >
>
> Oh! I bet the problem is that Jifty->new() isn't in a BEGIN {} block.
> Try that?
>

Indeed you are correct!

Putting C<Jifty->new()> into BEGIN {} works for me. So the boilerplate
actually look like this:

   use Jifty::Everything;
   BEGIN { Jifty->new; }

   use Qooqle::Model::QQUser;
   use Qooqle::Model::Session;
   use Qooqle::Model::Message;

Hmm, incredibly clean. :)

Maybe we should add this bit to Jifty::Manual::Models?

Cheers,
Agent


More information about the jifty-devel mailing list