diff --git a/django/contrib/formtools/wizard/views.py b/django/contrib/formtools/wizard/views.py
index 15ba146..22e6184 100644
a
|
b
|
from django.contrib.formtools.wizard.forms import ManagementForm
|
14 | 14 | |
15 | 15 | |
16 | 16 | def normalize_name(name): |
| 17 | """ |
| 18 | Converts camel-case style names into underscore seperated words. Example:: |
| 19 | |
| 20 | >>> normalize_name('oneTwoThree') |
| 21 | 'one_two_three' |
| 22 | >>> normalize_name('FourFiveSix') |
| 23 | 'four_five_six' |
| 24 | |
| 25 | """ |
17 | 26 | new = re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', name) |
18 | 27 | return new.lower().strip('_') |
19 | 28 | |
… |
… |
class WizardView(TemplateView):
|
169 | 178 | kwargs['form_list'] = init_form_list |
170 | 179 | return kwargs |
171 | 180 | |
172 | | def get_wizard_name(self): |
173 | | return normalize_name(self.__class__.__name__) |
174 | | |
175 | | def get_prefix(self): |
| 181 | def get_prefix(self, *args, **kwargs): |
176 | 182 | # TODO: Add some kind of unique id to prefix |
177 | | return self.wizard_name |
| 183 | return normalize_name(self.__class__.__name__) |
178 | 184 | |
179 | 185 | def get_form_list(self): |
180 | 186 | """ |
… |
… |
class WizardView(TemplateView):
|
210 | 216 | response gets updated by the storage engine (for example add cookies). |
211 | 217 | """ |
212 | 218 | # add the storage engine to the current formwizard instance |
213 | | self.wizard_name = self.get_wizard_name() |
214 | | self.prefix = self.get_prefix() |
| 219 | self.prefix = self.get_prefix(*args, **kwargs) |
215 | 220 | self.storage = get_storage(self.storage_name, self.prefix, request, |
216 | 221 | getattr(self, 'file_storage', None)) |
217 | 222 | self.steps = StepsHelper(self) |
… |
… |
class NamedUrlCookieWizardView(NamedUrlWizardView):
|
683 | 688 | A NamedUrlFormWizard with pre-configured CookieStorageBackend. |
684 | 689 | """ |
685 | 690 | storage_name = 'django.contrib.formtools.wizard.storage.cookie.CookieStorage' |
686 | | |
diff --git a/docs/ref/contrib/formtools/form-wizard.txt b/docs/ref/contrib/formtools/form-wizard.txt
index aadd7d2..59e68e2 100644
a
|
b
|
Advanced ``WizardView`` methods
|
314 | 314 | context.update({'another_var': True}) |
315 | 315 | return context |
316 | 316 | |
317 | | .. method:: WizardView.get_wizard_name() |
| 317 | .. method:: WizardView.get_prefix(*args, **kwargs) |
318 | 318 | |
319 | | This method can be used to change the wizard's internal name. |
320 | | |
321 | | Default implementation:: |
322 | | |
323 | | def get_wizard_name(self): |
324 | | return normalize_name(self.__class__.__name__) |
325 | | |
326 | | .. method:: WizardView.get_prefix() |
327 | | |
328 | | This method returns a prefix for the storage backends. These backends use |
329 | | the prefix to fetch the correct data for the wizard. (Multiple wizards |
330 | | could save their data in one session) |
| 319 | This method returns a prefix for use by the storage backends. Backends use |
| 320 | the prefix as a mechanism to allow data to be stored separately for each |
| 321 | wizard. This allows wizards to store their data in a single backend |
| 322 | without overwriting each other. |
331 | 323 | |
332 | 324 | You can change this method to make the wizard data prefix more unique to, |
333 | 325 | e.g. have multiple instances of one wizard in one session. |
334 | 326 | |
335 | 327 | Default implementation:: |
336 | 328 | |
337 | | def get_prefix(self): |
338 | | return self.wizard_name |
| 329 | def get_prefix(self, *args, **kwargs): |
| 330 | # use the lowercase underscore version of the class name |
| 331 | return normalize_name(self.__class__.__name__) |
339 | 332 | |
340 | 333 | .. method:: WizardView.get_form(step=None, data=None, files=None) |
341 | 334 | |