Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #17162 -- Removed the useless `WizardView.get_wizard_name()` me…

…thod. Thanks, Bradley Ayers and Stephan Jaekel.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17234 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1ef6841cade19b06508f74d8602acee0805e88b5 1 parent ed56e2c
Julien Phalip jphalip authored
19 django/contrib/formtools/wizard/views.py
View
@@ -14,6 +14,15 @@
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 @@ def get_initkwargs(cls, form_list, initial_dict=None,
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 @@ def dispatch(self, request, *args, **kwargs):
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)
23 docs/ref/contrib/formtools/form-wizard.txt
View
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.