#19298: MultiValueField should override __deepcopy__
---------------------------------+--------------------
     Reporter:  nick.phillips@…  |      Owner:  nobody
         Type:  Bug              |     Status:  new
    Component:  Forms            |    Version:  master
     Severity:  Normal           |   Keywords:
 Triage Stage:  Unreviewed       |  Has patch:  0
Easy pickings:  0                |      UI/UX:  0
---------------------------------+--------------------
 MultiValueField needs to override the default inherited from Field, as it
 needs to deep-copy subfields:

 {{{
     def __deepcopy__(self, memo):
         result = copy.copy(self)
         memo[id(self)] = result
         result.fields = copy.deepcopy(self.fields, memo)
         result.widget = copy.deepcopy(self.widget, memo)
         result.validators = self.validators[:]
         return result
 }}}

 or

 {{{
     def __deepcopy__(self, memo):
         result = super(MultiValueField, self).__deepcopy__(memo)
         result.fields = copy.deepcopy(self.fields, memo)
         return result
 }}}

 should be added to MultiValueField, if I'm right.

 Without this, any "MyClass" that subclasses MultiValueField and uses
 subfields with complex attributes (e.g. ChoiceField's "choices") will fail
 when re-used within the same view.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/19298>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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 https://groups.google.com/groups/opt_out.


Reply via email to