Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#18026 closed Bug (fixed)

can't update extra_data in process_step of form wizard

Reported by: creecode Owned by: steph
Component: contrib.formtools Version: 1.4
Severity: Normal Keywords: form wizard extra_data process_step can't update
Cc: aron@…, steph Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The WizardView.process_step documentation indicates that it is possible to set storage extra data but this appears not to be the case.

It seems the problem lies with the getter for extra_data when it finds an empty dict for extra_data it returns an anonymous dict instead of self.data[self.extra_data_key].

This is a one line change at https://code.djangoproject.com/browser/django/trunk/django/contrib/formtools/wizard/storage/base.py#L40 or there abouts.

def _get_extra_data(self):

return self.data[self.extra_data_key] or {}

...changes to...

def _get_extra_data(self):

return self.data[self.extra_data_key]

Credit to Ryan Show who identified the problem. I just wanted to get it into the tracker here as I've run into the problem myself.

Toodle-looooooooo........

creecode

Change History (9)

comment:1 by Aron Grififs, 13 years ago

Cc: aron@… added

comment:2 by Jannis Leidel, 13 years ago

Cc: steph added
Triage Stage: UnreviewedAccepted

comment:3 by steph, 13 years ago

Could you add a test for this issue? I think a setdefault instead of the anonymous dict before returning the extra data key would help. Maybe you could add a patch for this too - would be really cool!

comment:4 by andrea, 12 years ago

I suppose that the intended use of the extra_data property was as single value, not as dictionary.
What I mean is that you can do:

    mywizard.storage.extra_data = {'foo' : 'bar'}

but not

    mywizard.storage.extra_data['foo'] = 'bar'

Note that extra_data_key is a constant (extra_data_key = 'extra_data') in the BaseStorage class.

I think that if the intended use has to be changed, maybe a design decision is needed.

comment:5 by steph, 12 years ago

I just created a test for this problem and also added the fix. See https://github.com/stephrdev/django/commit/01c1b995f09344d61949ce0171f0df04acf8f845

comment:6 by steph, 12 years ago

Owner: changed from nobody to steph
Status: newassigned

comment:7 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In 97121cb96e2f9f02f977010b5549b88f1a73610b:

Fixed #18026 -- Don't return an anonymous dict if extra_data in storage is empty.

comment:8 by Claude Paroz <claude@…>, 12 years ago

In fb130cb40ea9b93bae741a4f359f19819597a112:

[1.5.x] Fixed #18026 -- Don't return an anonymous dict if extra_data in storage is empty.

Backport of 97121cb9 from master.

comment:9 by Claude Paroz <claude@…>, 12 years ago

In fb130cb40ea9b93bae741a4f359f19819597a112:

[1.5.x] Fixed #18026 -- Don't return an anonymous dict if extra_data in storage is empty.

Backport of 97121cb9 from master.

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