Django

Code

Show
Ignore:
Timestamp:
09/14/08 02:04:40 (4 months ago)
Author:
russellm
Message:

Fixed #8570: Corrected some code that was using 8-space tabs for some reason. Thanks to Manuel Saelices for the report.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/formtools/utils.py

    r8715 r9019  
    33except ImportError: 
    44    import pickle 
    5      
     5 
    66from django.conf import settings 
    77from django.utils.hashcompat import md5_constructor 
     
    99 
    1010def security_hash(request, form, *args): 
    11         """ 
    12         Calculates a security hash for the given Form instance. 
     11    """ 
     12    Calculates a security hash for the given Form instance. 
    1313 
    14         This creates a list of the form field names/values in a deterministic 
    15         order, pickles the result with the SECRET_KEY setting, then takes an md5 
    16         hash of that. 
    17         """ 
    18          
    19         data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] 
    20         data.extend(args) 
    21         data.append(settings.SECRET_KEY) 
    22          
    23         # Use HIGHEST_PROTOCOL because it's the most efficient. It requires 
    24         # Python 2.3, but Django requires 2.3 anyway, so that's OK. 
    25         pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL) 
    26          
    27         return md5_constructor(pickled).hexdigest() 
     14    This creates a list of the form field names/values in a deterministic 
     15    order, pickles the result with the SECRET_KEY setting, then takes an md5 
     16    hash of that. 
     17    """ 
    2818 
     19    data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] 
     20    data.extend(args) 
     21    data.append(settings.SECRET_KEY) 
     22 
     23    # Use HIGHEST_PROTOCOL because it's the most efficient. It requires 
     24    # Python 2.3, but Django requires 2.3 anyway, so that's OK. 
     25    pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL) 
     26 
     27    return md5_constructor(pickled).hexdigest() 
     28