Ejemplo n.º 1
0
    def _create_from_db (self, session_id, user_id, addr, create_time, 
        access_time, messages, tokens=[]):
        """
        Create a new session from database data.

        This goes through the new-style object function __new__ rather than
        through the __init__ function.
        """
        session = SqlQuixoteSession.__new__(SqlQuixoteSession)
        session.id = session_id
        session.user = canary.user.get_user_by_id(self.context, user_id)
        # FIXME: one '_' to be removed for qx-1.0
        #session.__remote_address = addr
        #session.__creation_time = create_time.ticks()
        #session.__access_time = access_time.ticks()
        try:
            session.__access_time = mktime(access_time.timetuple()).ticks()
            session.__creation_time = mktime(create_time.timetuple()).ticks()
        except AttributeError:
            session.__creation_time = create_time.ticks()
            session.__access_time = access_time.ticks()
        session.__remote_address = addr 
        
        session.messages = messages
        session._form_tokens = tokens.split('~~')

        return session
Ejemplo n.º 2
0
 def strptime(s, f):
     return mktime(time.strptime(s, f))