On 21 Nov 2005, at 03:12, Ian Holsman wrote:
so instead of having something like
class Article( meta.Model):
site = ForeignKey( core.site)
...
and then having to remember add 'sites__id__exact=SITE_ID' each time
you query the table.
you could do something like
class Article( meta.SiteModel):
...
and meta.SiteModel would
- add the site field for you
- automatically append sites_id_exact in ALL queries (by checking the
klass in things like function_get_values_iterator)
- modify the uniqueness contstraints of the other fields so that they
include the site in the key. (allowing you to have the same slug value
over multiple sites)
This is yet another case for some kind of mixin functionality.
Inheritance isn't really suitable for this because there are various
kinds of functionality we might want to add to a model, and multiple
inheritance is ugly. We really want something like:
class Article(meta.Model):
class Mixins:
site = SiteMixin()
taggable = TaggableMixin()
searchable = FullTextSearchMixin('headline', 'body')
etc.
Cheers,
Simon