Actually both of them would work with Mixins, too - and Mixins would
help making other stuff more simple. So it's more a case of "Mixins are
the more general way". I'm all for mixins, but I would love it if we
could do them just with Pythons multiple inheritance:
class Poll(meta.Mode, SiteMixin, SearchMixin('title')):
...
(Yes, that's a parameterized class up there. I am bad, I know ;-) )
That would require the "get rid of magic model modules", though, as
otherwise it's a real pain to build with the current dynamic module
creation code (yes, I tried to get MI to work with the current model
and stopped working on it, because it's just too complicated to do to
be worth it).
bye, Georg
class Article(meta.Model):
online = meta.BooleanField()
But now my views are littered with:
articles.get_list(online__exact=True)
I'd much prefer to have this online check to be done "behind the
scenes" so I don't forget to test for it in someplace....
If I changed my model to:
class Article(Model):
online = BooleanField()
class META:
where_constraints = {'online__exact': True}
would this return all the offline articles or would it return nothing?
offline_articles = articles.get_list(online__exact=False)
so instead of:
where_constraints = {'online__exact: True}
you would need:
where_constraints = ['online = true']
Unfortunately, this basically makes it impossible to retrieve any row
in the database that doesn't match the clause. So in my example, if
you set the online field to false, you can never retrieve that article
without resorting to altering the database outside of django.