On Sun, Nov 13, 2005 at 09:39:33PM -0600, Randall Smith wrote:
> Jason Chu wrote:
> >I read a little bit of discussion on mixin classes in the archives, but
> >nothing was finalized.
> >My use case sounds something like this:
> >- I have objects I want to track last modified date and deleted attribute on
> >- Code will be exactly the same between totally disparate classes
> >Having one class Modifiable to do the modified date stuff works fine.
> >Having one class Deletable also works fine.
> >If something is Modifiable, it's a subclass of Modifiable. I'm know this
> >isn't how sqlobject.inheritance is supposed to work, but I'm pretty sure
> >this is how SQLObject inheritance is supposed to work (line 273 of main.py).
> >The problem is when I want something to be Modifiable and Deletable. The
> >new class only gets the columns from the first parent and ignores the
> >second one. I think this is also because of line 273 from main.py, but I
> >couldn't figure out how to make it take the columnDefinitions from all
> >parents.
> >Instead I wrote a small ugly patch to do something like _inheritable does.
> >It uses _mixIn and will add all columns from mixed in parent classes to
> >children.
> >There are lots of limitations and side-effects:
> >- I don't know how it fits with sqlobject.inheritance.
> >- It doesn't mixin joins or indexes.
> >- The first parent's columns are still included by SQLObject inheritance,
> >which I'm sure will have weird side-effects later on.
> >I figured I'd send the patch just to get some discussion going about mixins
> >though. If they're not the best solution for this case, then feel free to
> >say that as well.
> >Jason
>
> I am dealing with the same issue. What did you end up doing?
>
> Randall
I realize you probably don't need this anymore (I see you're looking for a
different solution in 0.7), but if anyone else needs this, I wrote up
something about it in my blog:
http://xentac.net/~jchu/blog/technology/sqlobject-event-fu.html
Jason
--
If you understand, things are just as they are. If you do not understand,
things are just as they are.