

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