[jifty-devel] Plugins that have their own models

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Mon Jul 16 22:17:02 EDT 2007


I assumed as much. I thought that perhaps someone was thinking that at some
point you could make a Jifty::Record abstract by croaking in table().
Commits may be coming shortly.

On 7/16/07, Jesse Vincent <jesse at bestpractical.com> wrote:
>
>
> On Jul 16, 2007, at 6:07 PM, Andrew Sterling Hanenkamp wrote:
>
> > Glurg. Okay, I went to clean up and test everything before
> > committing this patch and discovered a initialization problem. It's
> > trying to call $model->table for the plugin models, which calls
> > $model->_guess_table_name, but this happens before plugin class
> > itself is configured, which means that the table name will never be
> > prefixed, which is undesirable.
> >
> > I have traced it back into the class loader, which runs this
> > snippet while loading the models around line 168, which is run
> > while generating the model action classes (which happens
> > automatically upon creation of a Jifty::ClassLoader instance):
> >
> >     local $@;
> >             eval { $modelclass->table } ;
> >         if(!$@) {
> >
> >         return $self->return_class(
> >                   "package $module;\n"
> >                 . "use base qw/$base\::Action::Record::$1/;\n"
> >                 . "sub record_class { '$modelclass' };\n"
> >                 . "sub autogenerated { 1 };\n"
> >             );
> >         }
> >
> > If I understand what's going on here, it's checking to see if the
> > model provides a valid and non-failing implementation of the table
> > () method to determine whether or not to actually build the action
> > classes. A similar check is in place for creating the model event
> > class too.
> >
> > Is this necessary? If so, I can look for another way to short-
> > circuit the process until the plugins are initialized. If not, what
> > other check would suffice? I'm not certain as for the purpose of
> > this at all, so I'm not sure what to do about it.
>
> I bet that's just duck-typing. perhaps an ->isa check?
>
> -j
>
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070716/67ba0143/attachment.htm


More information about the jifty-devel mailing list