From 90ff521e4edc371da00ca04e587505746ff97e90 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 16 Jan 2006 23:27:59 +0000 Subject: [PATCH] magic-removal: Simplified overengineered 'attribute_transforms' code in django/db/models/base.py git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2018 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/base.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/django/db/models/base.py b/django/db/models/base.py index 80e52388f4..a34a5af29d 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -20,8 +20,6 @@ import os if not hasattr(__builtins__, 'set'): from sets import Set as set -attribute_transforms = {'Admin': lambda cls: AdminOptions(**dict([(k,v) for (k,v) in cls.__dict__.items() if not k.startswith('_')]))} - class ModelBase(type): "Metaclass for all models" def __new__(cls, name, bases, attrs): @@ -109,9 +107,8 @@ class Model(object): dispatcher.send(signal=signals.post_init, sender=self.__class__, instance=self) def add_to_class(cls, name, attribute): - transform = attribute_transforms.get(name, None) - if transform: - attribute = transform(attribute) + if name == 'Admin': + attribute = AdminOptions(**dict([(k, v) for k, v in attribute.__dict__.items() if not k.startswith('_')])) if hasattr(attribute, 'contribute_to_class'): attribute.contribute_to_class(cls, name) else: