Actually, maybe it is working. I should have been looking for _meta rather than _meta_ .
But does anyone have an opinion about subclassing models.Model.__metaclass__ ? Bill On Tue, Sep 8, 2009 at 4:35 PM, Bill Freeman<[email protected]> wrote: > I'm trying to use an Abstract Base Class as described at: > > http://docs.djangoproject.com/en/dev/topics/db/models/#abstract-base-classes > > (Django 1.1, Python 2.6.2) > > Things may be complicated by my desire to use a mixin: > > class Mixin(object): > """I will actually be creating some of these that aren't model instances""" > def _setFoo(self, v): > self._inner_foo = ... > > def _getFoo(self): > ... > > foo = property(_getFoo, _setFoo) > > # and other methods that process self that has _inner_foo > > class AbsModel(models.Model, Mixin): > _inner_foo = models.FloatFiedl(...) > > class Meta: > abstract = True > > class Thing(AbsModel): > """I want to use the property and methods from Mixin on these instances > and on instances of other subclasses of AbsModel without having to > define _inner_foo as a field in each lexical class definition (there are > actually a number of fields).""" > # Other fields > # Other methods > > x = Thing() > > So far, so good. But, while x is an instance of models.Model, it is > not an instance of Mixin (according to isinstance, and also according > to the lack of a foo property). > > I can make it seem to work by changing the Meta class declaration to: > > class Meta(models.Model.__metaclass__): > > The property is there, and isinstance reports that x is an instance of > both, but now Thing doesn't have a _meta_ attribute (so it doesn't > have fields). > > Is this a bug in the Abstract Base Class mechanism, my efforts, or both? > > Bill > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" 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-users?hl=en -~----------~----~----~----~------~----~------~--~---

