[jifty-devel] Handling register_triggers with mixins on virtual
models
Andrew Sterling Hanenkamp
sterling at hanenkamp.com
Wed Aug 22 12:50:49 EDT 2007
I ran into an interesting issue today. I'm having some trouble testing a
database-backed class that uses a mixin, but needs to register triggers for
a column that is created after register_triggers() has already been called.
Which is pretty much always the case unless you reload Jifty completely
after creating all the columns.
I can think of a couple good solutions and I'm thinking of implementing
both:
1. Virtual models branch change: Add a new
register_triggers_late()method that is only called on database-backed
models when a column is
created after register_triggers() has been called. It would pass the
new column info to the method so it could do any column-specific trigger
updates. This would allow a mixin that may need to implement additional
triggers on new database-backed columns to do so without mucking with the
existing API.
2. Trunk change: Add two new "pseudo-triggers" before_any_set and
after_any_set. Setting a before_any_set trigger would cause a
before_set_X trigger to be set for every column on the table. The
after_any_set trigger would do the same for after_set_X. The virtual
models branch would then add these triggers to any new column as they are
created as well.
Any objections/suggestions?
Cheers,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bestpractical.com/pipermail/jifty-devel/attachments/20070822/72313b13/attachment.htm
More information about the jifty-devel
mailing list