'Use the given session to control (puppet) the given object (usually
a Character type).
Args:
session (Session): session to use for puppeting
obj (Object): the object to start puppeting
Raises:
RuntimeError: If puppeting is not possible, the
`exception.msg` will contain the reason.'

def puppet_object(self, session, obj):

    if (not obj):
        raise RuntimeError('Object    not    found')
    if (not session):
        raise RuntimeError('Session    not    found')
    if (self.get_puppet(session) == obj):
        self.msg('You    are    already    puppeting    this    object.')
        return
    if (not obj.access(self, 'puppet')):
        self.msg(("You    don't    have    permission    to    puppet    '%s'." % obj.key))
        return
    if obj.player:
        if (obj.player == self):
            if obj.sessions.count():
                if (_MULTISESSION_MODE in (1, 3)):
                    txt1 = 'Sharing    |c%s|n    with    another    of    your    sessions.'
                    txt2 = '|c%s|n|G    is    now    shared    from    another    of    your    sessions.|n'
                    self.msg((txt1 % obj.name), session=session)
                    self.msg((txt2 % obj.name), session=obj.sessions.all())
                else:
                    txt1 = 'Taking    over    |c%s|n    from    another    of    your    sessions.'
                    txt2 = '|c%s|n|R    is    now    acted    from    another    of    your    sessions.|n'
                    self.msg((txt1 % obj.name), session=session)
                    self.msg((txt2 % obj.name), session=obj.sessions.all())
                    self.unpuppet_object(obj.sessions.get())
        elif obj.player.is_connected:
            self.msg(('|c%s|R    is    already    puppeted    by    another    Player.' % obj.key))
            return
    if session.puppet:
        self.unpuppet_object(session)
    obj.at_pre_puppet(self, session=session)
    obj.sessions.add(session)
    obj.player = self
    session.puid = obj.id
    session.puppet = obj
    obj.scripts.validate()
    obj.locks.cache_lock_bypass(obj)
    obj.at_post_puppet()
