Opened 18 years ago

Last modified 17 years ago

#3489 closed

altering local newforms Formfields fails cause self.fields isnt a deep copy — at Initial Version

Reported by: Ronny Pfannschmidt <ronny.pfannschmidt@…> Owned by: nobody
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

take a look at the test

"""
>>> TestForm({'text':"foo"}).is_valid()
True

>>> TestForm({'text':"foo"},need_name=True).is_valid()
False

>>> TestForm({'text':"foo"}).is_valid() #this one will fail
True

"""
from django.newforms import *
class TestForm(Form):
    name = CharField(max_length=30)
    text = CharField(widget=Textarea)
    def __init__(self,*k,**kw):
        need_name=kw.pop("need_name",False)
        Form.__init__(self,*k,**kw)

        if need_name:
            self.fields["name"].required=True

just assigning need_name to self.fieldsname.required would create a race-condition for multithreaded servers

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top