[jifty-devel] Plugins that have their own models
jesse at bestpractical.com
Mon Jul 16 13:07:15 EDT 2007
On Jul 15, 2007, at 11:08 PM, Andrew Sterling Hanenkamp wrote:
> 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
> 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.
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 186 bytes
Desc: This is a digitally signed message part
Url : http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070716/82fa4786/PGP.pgp
More information about the jifty-devel