Disable R0801 messages in pylintrc. R0801 messages indicates that a set of similar lines has been detected among multiple file. This usually means that the code should be refactored to avoid this duplication but in our case it's useless since it shows a lot of imports code or authors.
Patch by: Pawel Solyga
Review by: to-be-reviewed
try: import cPickle as pickleexcept ImportError: import picklefrom django.conf import settingsfrom django.utils.hashcompat import md5_constructorfrom django.forms import BooleanFielddef security_hash(request, form, *args): """ Calculates a 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, then takes an md5 hash of that. """ data = [(bf.name, bf.field.clean(bf.data) or '') for bf in form] data.extend(args) data.append(settings.SECRET_KEY) # Use HIGHEST_PROTOCOL because it's the most efficient. It requires # Python 2.3, but Django requires 2.3 anyway, so that's OK. pickled = pickle.dumps(data, pickle.HIGHEST_PROTOCOL) return md5_constructor(pickled).hexdigest()