Django

Code

Changeset 6450

Show
Ignore:
Timestamp:
10/03/07 20:12:00 (1 year ago)
Author:
mtredinnick
Message:

Added a deepcopy() method to the Widget class in order to avoid a number of easy-to-trigger problems when copying Widget subclasses. Subclasses which are intended to have extra mutable fields should override this method. Refs #5505.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/widgets.py

    r6273 r6450  
    88    from sets import Set as set   # Python 2.3 fallback 
    99 
     10import copy 
    1011from itertools import chain 
     12 
    1113from django.utils.datastructures import MultiValueDict 
    1214from django.utils.html import escape 
     
    3234        else: 
    3335            self.attrs = {} 
     36 
     37    def __deepcopy__(self, memo): 
     38        obj = copy.copy(self) 
     39        obj.attrs = self.attrs.copy() 
     40        memo[id(self)] = obj 
     41        return obj 
    3442 
    3543    def render(self, name, value, attrs=None):