'Encode the value for the attribute.'

def _Encode(self, value):

    try:
        return value.SerializeToString().encode('hex')
    except AttributeError:
        if isinstance(value, (int, long)):
            return str(value).encode('hex')
        else:
            return utils.SmartStr(value).encode('hex')
