Opened 12 years ago

Last modified 8 years ago

#7038 closed

FormWizard fails on forms with BooleanField when field is unselected — at Initial Version

Reported by: anonymous Owned by: nobody
Component: contrib.formtools Version: master
Severity: Keywords: FormWizard, BooleanField, hash failure
Cc: rajesh.dhawan@…, dev@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The form wizard fails to match its security hash when processing a form containing at least one BooleanField where the BooleanField's checkbox is unselected (e.g. False). This results in (on my machine) the form containing the BooleanField being redisplayed. If *all* the BooleanFields on a form are selected, it appears to work correctly.

I was able to workaround (not fix) by overriding the security_hash method as follows:

def security_hash(self, request, form):

for bf in form:

if bf.field.class != BooleanField:

data = [(bf.name, bf.data or u)] + [settings.SECRET_KEY]

# Use HIGHEST_PROTOCOL because it's the most efficient. It requires
# Python 2.3, but Django requires 2.3 anyway, so that's OK.
pickled = pickle.dumps(data, protocol=pickle.HIGHEST_PROTOCOL)
return md5.new(pickled).hexdigest()

The problem appears (to my untrained eye) to be in the line assigning the value of data where bf.data = False and thus gets assigned .

I'm using SVN 7412.

Change History (0)

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