[jifty-devel] Plugins that have their own models
Andrew Sterling Hanenkamp
sterling at hanenkamp.com
Mon Jul 16 14:52:39 EDT 2007
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.
On 7/16/07, Jesse Vincent <jesse at bestpractical.com> wrote:
> On Jul 15, 2007, at 11:08 PM, Andrew Sterling Hanenkamp wrote:
> > Jesse,
> > We've discussed it before and I believe it was your intention that
> > plugins be able to supply their own models. Up to this point, it
> > has not been possible. I have created a patch that will make it
> > possible, but I've not committed it yet. I wanted to run it by you
> > first to make sure I haven't stepped in anything.
> This is very cool. My one concern is plugins offering models of the
> same name as the user app and what happens. Is that something you've
> thought about or played with?
> > You can find the patch attached. It includes modifications to
> > Jifty::Plugin, Jifty::Schema, and Jifty::Script::Schema along with
> > a new test application and a single test that verifies the basics.
> > (I'm planning a couple more to make sure that plugin models
> > cooperate properly with app models and that upgrades work.)
> > Anyway, the major fix is in two areas:
> > Jifty::Schema now includes any models found under installed plugins
> > and adds them to Jifty->schema->models
> > Jifty::Script::Schema now iterates through installed plugins when
> > checking for installation and upgrades.
> > Supporting the later piece, I have added some new methods to
> > Jifty::Plugin that are inherited with the expected defaults:
> > $plugin->version: Returns the database version of the plugin.
> > Returns 0.0.1 unless overridden.
> > $plugin->bootstrapper: Returns the bootstrap class for the plugin.
> > Returns $plugin_class::Bootstrap unless overidden.
> > $plugin->upgrade_class: Returns the bootstrap class for the plugin.
> > Returns $plugin_class::Upgrade unless overridden.
> > That's it. Thanks to Jesse and Alex, et. al. this patch was pretty
> > simple.
> > Oh, there is one possible nasty you may run into (at least I did).
> > I had installed an old version of Jifty at some point where
> > Authentication::Password and the User plugins had User models. This
> > caused bad things to happen.
> > I also wonder if each plugin might want to supply a prefix to the
> > table names to avoid collisions.
> > Cheers,
> > Andrew
> > <plugin-models.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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jifty-devel