Package django :: Package contrib :: Package formtools :: Module preview :: Class FormPreview
[hide private]
[frames] | no frames]

Class FormPreview

source code

object --+
         |
        FormPreview

Instance Methods [hide private]
 
__init__(self, form)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__call__(self, request, *args, **kwargs) source code
 
unused_name(self, name)
Given a first-choice name, adds an underscore to the name until it reaches a name that isn't claimed by any field in the form.
source code
 
preview_get(self, request)
Displays the form
source code
 
preview_post(self, request)
Validates the POST data.
source code
 
post_post(self, request)
Validates the POST data.
source code
 
parse_params(self, *args, **kwargs)
Given captured args and kwargs from the URLconf, saves something in self.state and/or raises Http404 if necessary.
source code
 
security_hash(self, request, form)
Calculates the security hash for the given Form instance.
source code
 
failed_hash(self, request)
Returns an HttpResponse in the case of an invalid security hash.
source code
 
done(self, request, cleaned_data)
Does something with the cleaned_data and returns an HttpResponseRedirect.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  preview_template = 'formtools/preview.html'
  form_template = 'formtools/form.html'
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, form)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

unused_name(self, name)

source code 

Given a first-choice name, adds an underscore to the name until it reaches a name that isn't claimed by any field in the form.

This is calculated rather than being hard-coded so that no field names are off-limits for use in the form.

preview_post(self, request)

source code 

Validates the POST data. If valid, displays the preview page. Else, redisplays form.

post_post(self, request)

source code 

Validates the POST data. If valid, calls done(). Else, redisplays form.

parse_params(self, *args, **kwargs)

source code 

Given captured args and kwargs from the URLconf, saves something in
self.state and/or raises Http404 if necessary.

For example, this URLconf captures a user_id variable:

    (r'^contact/(?P<user_id>\d{1,6})/$', MyFormPreview(MyForm)),

In this case, the kwargs variable in parse_params would be
{'user_id': 32} for a request to '/contact/32/'. You can use that
user_id to make sure it's a valid user and/or save it for later, for
use in done().

security_hash(self, request, form)

source code 

Calculates the security hash for the given Form instance.

This creates a list of the form field names/values in a deterministic order, pickles the result with the SECRET_KEY setting and takes an md5 hash of that.

Subclasses may want to take into account request-specific information such as the IP address.