Django

Code

Changeset 2018

Show
Ignore:
Timestamp:
01/16/06 17:27:59 (3 years ago)
Author:
adrian
Message:

magic-removal: Simplified overengineered 'attribute_transforms' code in django/db/models/base.py

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/django/db/models/base.py

    r1977 r2018  
    2020if not hasattr(__builtins__, 'set'): 
    2121    from sets import Set as set 
    22  
    23 attribute_transforms = {'Admin': lambda cls: AdminOptions(**dict([(k,v) for (k,v) in cls.__dict__.items() if not k.startswith('_')]))} 
    2422 
    2523class ModelBase(type): 
     
    110108 
    111109    def add_to_class(cls, name, attribute): 
    112         transform = attribute_transforms.get(name, None) 
    113         if transform: 
    114             attribute = transform(attribute) 
     110        if name == 'Admin': 
     111            attribute = AdminOptions(**dict([(k, v) for k, v in attribute.__dict__.items() if not k.startswith('_')])) 
    115112        if hasattr(attribute, 'contribute_to_class'): 
    116113            attribute.contribute_to_class(cls, name)