def post_message_to_user(self, msg_text, user,
                             sender=None, msg_type='announcement'):
        '''
        send a message to a user
        
        @param msg_text: the text of the message
        @type msg_text: string
        @param user: the receiver of the message or her username
        @type user: L{django.contrib.auth.models.User} or string
        @param sender: the user sending the message. Default None.
        @type sender: L{django.contrib.auth.models.User}
        @param msg_type: the message type. One of DatedMessage.TYPE_*
            Defaults to DatedMessage.TYPE_ANNOUNCE
        @type msg_type: One of DatedMessage.TYPE_*
        '''

        max_length = DatedMessage._meta.get_field("msg_text").max_length
        
        if type(user) == User:
            rcvr = user
        else:
            rcvr = User.objects.get(username=user)
            
        m = self.create(msg_text=msg_text[:max_length], type=msg_type, sender=sender)
        m.users.add(rcvr)
dataset/ETHPy150Open fp7-ofelia/ocf/expedient/src/python/expedient/common/messaging/models.py/DatedMessageManager.post_message_to_user/original