Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Thu, 2008-07-03 at 02:06 -0700, Christian wrote: > [...] > > Should I send in patches for django.db.models.ModelBase, > > django.newforms.DeclarativeFieldsMetaclass, and > > django.newforms.MediaDefiningClass? > > Sounds like a reasonable idea. Make patches against the right branches, > though, please. DeclarativeFieldsMetaclass and ModelBase should be > patched on trunk (and will then be absorbed into newforms-admin when > they next merge from trunk). MediaDefiningClass is a newforms-admin only > class, so that patch is directly for them. > > Probably worth, therefore, having two tickets so that one is assigned to > version "SVN" and the other is version "newforms-admin". http://code.djangoproject.com/ticket/7621 "SVN" http://code.djangoproject.com/ticket/7620 "newforms-admin" Looking at ModelBase, another question came up: > class ModelBase(type): > "Metaclass for all models" > def __new__(cls, name, bases, attrs): > # If this isn't a subclass of Model, don't do anything special. > try: > parents = [b for b in bases if issubclass(b, Model)] > except NameError: > # 'Model' isn't defined yet, meaning we're looking at Django's own > # Model class, defined below. > parents = [] > if not parents: > return super(ModelBase, cls).__new__ (cls, name, bases, attrs) > ... If I understand that correctly, the intent here is to `...` only for classes derived from `Model` but not for `Model` itself. I'd propose to write that check as parents = [b for b in bases if isinstance(b, ModelBase)] if parents: return super(ModelBase, cls).__new__ (cls, name, bases, attrs) ... Simpler, and it allows several independent `Model` classes using the same metaclass, if that's ever necessary. -- Christian Tanzer http://www.c-tanzer.at/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---