add ChecksumPage mixin

This commit is contained in:
smurail 2014-10-20 13:21:43 +02:00
commit a6a7130b31

View file

@ -570,3 +570,17 @@ class LoggedPage(object):
pages with a login form.
"""
logged = True
class ChecksumPage(object):
"""
Compute a checksum of raw content before parsing it.
"""
import hashlib
hashfunc = hashlib.md5
checksum = None
def build_doc(self, content):
self.checksum = self.hashfunc(content).hexdigest()
return super(ChecksumPage, self).build_doc(content)