[jifty-devel] Plugins that have their own models

Andrew Sterling Hanenkamp sterling at hanenkamp.com
Mon Jul 16 18:07:54 EDT 2007


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.


On 7/16/07, Jesse Vincent <jesse at bestpractical.com> wrote:
>
>
> On Jul 16, 2007, at 3:21 PM, Andrew Sterling Hanenkamp wrote:
>
> Done. It required the addition I already mentioned to Jifty::Plugin as
> well as a modification to Jifty::Record to improve _guess_table_name().
>
> I've attached an updated patch.
>
>
> +1. I'm good with this.
>
>
>
> On 7/16/07, Jesse Vincent <jesse at bestpractical.com> wrote:
> >
> >
> > On Jul 16, 2007, at 2:52 PM, Andrew Sterling Hanenkamp wrote:
> >
> > > Sorry, I make my emails too long. As the dorky consultants around
> > > the office say, quoting my Kolbe score, my red line is too long.
> > >
> > > This little nugget was the last line of my original message:
> > >
> > > > I also wonder if each plugin might want to supply a prefix to the
> > > table names to avoid collisions.
> > >
> > > My patch doesn't include that. It was a thought I had as I finished
> > > the email. It should be pretty easy to add by adding something like
> > > "table_prefix()" to the Jifty::Plugin that could be overridden and
> > > just calculates a preset table prefix from the plugin's name.
> >
> > I suspect that's probably the right thing.
> >
> > _______________________________________________
> > jifty-devel mailing list
> > jifty-devel at lists.jifty.org
> > http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
> >
> >
> >
> <plugin-models2.patch>_______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>
>
>
> _______________________________________________
> 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/89d433fb/attachment.htm


More information about the jifty-devel mailing list