コード例 #1
0
ファイル: dbserialize.py プロジェクト: helix-0311/evennia
def pack_session(item):
    """
    Handle the safe serializion of Sessions objects (these contain
    hidden references to database objects (players, puppets) so they
    can't be safely serialized).

    Args:
        item (Session)): This item must have all properties of a session
            before entering this call.

    Returns:
        packed (tuple or None): A session-packed tuple on the form
            `(__packed_session__, sessid, conn_time)`. If this sessid
            does not match a session in the Session handler, None is returned.

    """
    _init_globals()
    session = _SESSION_HANDLER.get(item.sessid)
    if session and session.conn_time == item.conn_time:
        # we require connection times to be identical for the Session
        # to be accepted as actually being a session (sessids gets
        # reused all the time).
        return item.conn_time and item.sessid and ('__packed_session__',
                                                   _GA(item, "sessid"),
                                                   _GA(item, "conn_time"))
    return None
コード例 #2
0
def pack_session(item):
    """
    Handle the safe serializion of Sessions objects (these contain
    hidden references to database objects (accounts, puppets) so they
    can't be safely serialized).

    Args:
        item (Session)): This item must have all properties of a session
            before entering this call.

    Returns:
        packed (tuple or None): A session-packed tuple on the form
            `(__packed_session__, sessid, conn_time)`. If this sessid
            does not match a session in the Session handler, None is returned.

    """
    _init_globals()
    session = _SESSION_HANDLER.get(item.sessid)
    if session and session.conn_time == item.conn_time:
        # we require connection times to be identical for the Session
        # to be accepted as actually being a session (sessids gets
        # reused all the time).
        return (item.conn_time and item.sessid
                and ("__packed_session__", _GA(
                    item, "sessid"), _GA(item, "conn_time")))
    return None
コード例 #3
0
ファイル: test.py プロジェクト: OakInnovations/ChosenMU
 def func(self):
     caller = self.caller
     sessions = SESSION_HANDLER.get_sessions()
     caller.msg("All Sessions")
     caller.msg(sessions)
     caller.msg("Individual sessions:")
  
     for session in sessions:
         caller.msg("Session: " + str(session))
         if not session.logged_in: continue
         character = session.get_puppet()
         caller.msg(character)
         character.msg("This is a test")
コード例 #4
0
ファイル: utils.py プロジェクト: icanbeyourmuse/Atharia
def announce_weather(text=None):
    """
    Announces weather to everyone who cares about it.
    :param text: The emit to show.
    """
    if not text:
        return

    for sess in SESSION_HANDLER.get_sessions():
        account = sess.get_account()
        if account:
            ignore_weather = account.db.ignore_weather or False
            if not ignore_weather:
                sess.msg("|wWeather:|n {}".format(text))
コード例 #5
0
def unpack_session(item):
    """
    Check and convert internal representations back to Sessions.

    Args:
        item (packed_session): The fact that item is a packed session
            should be checked before this call.

    Returns:
        unpacked (any): Either the original input or converts the
            internal store back to a Session. If Session no longer
            exists, None will be returned.
    """
    _init_globals()
    session = _SESSION_HANDLER.get(item[1])
    if session and session.conn_time == item[2]:
        # we require connection times to be identical for the Session
        # to be accepted as the same as the one stored (sessids gets
        # reused all the time).
        return session
    return None
コード例 #6
0
ファイル: dbserialize.py プロジェクト: helix-0311/evennia
def unpack_session(item):
    """
    Check and convert internal representations back to Sessions.

    Args:
        item (packed_session): The fact that item is a packed session
            should be checked before this call.

    Returns:
        unpacked (any): Either the original input or converts the
            internal store back to a Session. If Session no longer
            exists, None will be returned.
    """
    _init_globals()
    session = _SESSION_HANDLER.get(item[1])
    if session and session.conn_time == item[2]:
        # we require connection times to be identical for the Session
        # to be accepted as the same as the one stored (sessids gets
        # reused all the time).
        return session
    return None