Example #1
0
 def post_update(self, attr):
     """Trigger that is executed after an attribute update."""
     super(Message, self).post_update(attr)
     # Automatically keep the message hash up to date.
     if attr.name == 'message':
         value = attr.value()
         # MD5 works only on bytes, not on unicode
         if isinstance(value, unicode):
             value = value.encode('utf-8')
         self['hash'] = md5sum(value)
Example #2
0
 def hash(self, message):
     """Return a unique message id for `message'."""
     # MD5 works on bytes, not on unicode
     if isinstance(message, unicode):
         message = message.encode('utf-8')
     return md5sum(message)