Fixed #17162 -- Removed the useless `WizardView.get_wizard_name()` method. Thanks, Bradley Ayers and Stephan Jaekel.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17234 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Julien Phalip 2011-12-19 13:13:41 +00:00
parent ed56e2c4a8
commit 1ef6841cad
2 changed files with 20 additions and 22 deletions

View File

@ -14,6 +14,15 @@ from django.contrib.formtools.wizard.forms import ManagementForm
def normalize_name(name):
"""
Converts camel-case style names into underscore seperated words. Example::
>>> normalize_name('oneTwoThree')
'one_two_three'
>>> normalize_name('FourFiveSix')
'four_five_six'
"""
new = re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))', '_\\1', name)
return new.lower().strip('_')
@ -169,12 +178,9 @@ class WizardView(TemplateView):
kwargs['form_list'] = init_form_list
return kwargs
def get_wizard_name(self):
return normalize_name(self.__class__.__name__)
def get_prefix(self):
def get_prefix(self, *args, **kwargs):
# TODO: Add some kind of unique id to prefix
return self.wizard_name
return normalize_name(self.__class__.__name__)
def get_form_list(self):
"""
@ -210,8 +216,7 @@ class WizardView(TemplateView):
response gets updated by the storage engine (for example add cookies).
"""
# add the storage engine to the current formwizard instance
self.wizard_name = self.get_wizard_name()
self.prefix = self.get_prefix()
self.prefix = self.get_prefix(*args, **kwargs)
self.storage = get_storage(self.storage_name, self.prefix, request,
getattr(self, 'file_storage', None))
self.steps = StepsHelper(self)

View File

@ -314,28 +314,21 @@ Advanced ``WizardView`` methods
context.update({'another_var': True})
return context
.. method:: WizardView.get_wizard_name()
.. method:: WizardView.get_prefix(*args, **kwargs)
This method can be used to change the wizard's internal name.
Default implementation::
def get_wizard_name(self):
return normalize_name(self.__class__.__name__)
.. method:: WizardView.get_prefix()
This method returns a prefix for the storage backends. These backends use
the prefix to fetch the correct data for the wizard. (Multiple wizards
could save their data in one session)
This method returns a prefix for use by the storage backends. Backends use
the prefix as a mechanism to allow data to be stored separately for each
wizard. This allows wizards to store their data in a single backend
without overwriting each other.
You can change this method to make the wizard data prefix more unique to,
e.g. have multiple instances of one wizard in one session.
Default implementation::
def get_prefix(self):
return self.wizard_name
def get_prefix(self, *args, **kwargs):
# use the lowercase underscore version of the class name
return normalize_name(self.__class__.__name__)
.. method:: WizardView.get_form(step=None, data=None, files=None)