On 3/31/06, Joseph Kocherhans <[EMAIL PROTECTED]> wrote:
>
> Could anyone who want's mixins post some specific use cases
> (preferably simple code samples) Basically, are people wanting
> multiple inheritace for models, or do you just want a mixin to provide
> some additional methods? I'm reasearching model inheritance a bit
> more, and realized that I have no idea what people are looking for
> when they say "I want mixins".

Here's a use case for something that I'm actually working on:  An
administrative tool for djbdns's tinydns. Record format details are
here:

http://cr.yp.to/djbdns/tinydns-data.html

General idea is to have one class/table for each record type. Note
that all the records have some common elements: domain, ttl, timestamp
(which I'm doing as starts and expires timestamps), and location.
Additionally I would add some per-record metadata: added and updated.
Also there would be some common methods.

At present (in magic-removal), If I make a BaseRecord type with all
the common attributes and then make other records subclass it (not
exactly what you are asking for with mixins), I can create new entries
fine, but I can't access them through the admin interface because it
tries to pull them out of the wrong table (the superclass table).

I also tried having the common elements as a mixin, but that didn't
work right either. (I may have to revisit this, though.)

I have some notes on the ModelInheritance page about possibly using
views to simplify reading, and while none of the databases I could
find could do a multi-table update through a view without writing
stored procecures and triggers, I realized that individually updating
the underlying tables is no worse than if you didn't use views. So
views seem to be a win for reading and neutral for writing.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to