[jifty-devel] Plugins that have their own models

Jesse Vincent jesse at bestpractical.com
Mon Jul 16 21:23:27 EDT 2007

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?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070716/99ea557a/PGP.pgp

More information about the jifty-devel mailing list