示例#1
0
 def __init__(self, sessid=None):
     self.id = None
     self.modified = False
     self.destroyed = False
     if sessid is None:
         self._session = SessionData(self.get_new_sessid())
     else:
         self._session = SessionData.get(sessid)
         if self._session is None:
             self._session = SessionData(sessid)
             self.modified = True
示例#2
0
 def __init__(self, sessid=None):
     self.id = None
     self.modified = False
     self.destroyed = False
     if sessid is None:
         self._session = SessionData(self.get_new_sessid())
     else:
         self._session = SessionData.get(sessid)
         if self._session is None:
             self._session = SessionData(sessid)
             self.modified = True
示例#3
0
class SessionWrapper(object):
    """This class works like a UserDict.
    
    Example:
    
    >>> session = SessionWrapper()
    >>> session['a-key'] = 'other value'
    # to clear the attribute, simply:
    >>> del session['a-key']
    
    """
    user = property(lambda self: self.get("umit_user"))
    def __init__(self, sessid=None):
        self.id = None
        self.modified = False
        self.destroyed = False
        if sessid is None:
            self._session = SessionData(self.get_new_sessid())
        else:
            self._session = SessionData.get(sessid)
            if self._session is None:
                self._session = SessionData(sessid)
                self.modified = True

    def get_new_sessid(self):
        """Generates a new session ID."""
        junk = "çoa^wer098~73°0£24q¢ßðæ3w4w98948512397&*@#$!@#*()"
        return md5.new(str(random.randint(0, sys.maxint-1)) \
                                  + str(random.randint(1, sys.maxint-1)//2) \
                                  + junk).hexdigest()
    
    def get_sessid(self):
        """Return the ID of the session"""
        return self._session.id

    def __setitem__(self, name, value):
        self._session.pickled_data[name] = value
        self.modified = True

    def __getitem__(self, name):
        return self._session.pickled_data[name]

    def __delitem__(self, name):
        del self._session.pickled_data[name]
        self.modified = True

    def keys(self):
        return self._session.pickled_data.keys()
    
    def has_key(self, key):
        return self._session.pickled_data.has_key(key)

    def items(self):
        return self._session.pickled_data.items()

    def get(self, name, default=None):
        return self._session.pickled_data.get(name, default)

    def save(self):
        self._session.save()
        
    def destroy(self):
        """Destroy the current session."""
        self._session.delete()
        self._session = None
        self.modified = False
        self.destroyed = True
        
    @classmethod
    def clear(self):
        """Class method to clear all data in the database."""
        sessions = SessionData.get_list()
        if sessions:
            for session in sessions:
                session.delete()
示例#4
0
 def clear(self):
     """Class method to clear all data in the database."""
     sessions = SessionData.get_list()
     if sessions:
         for session in sessions:
             session.delete()
示例#5
0
class SessionWrapper(object):
    """This class works like a UserDict.
    
    Example:
    
    >>> session = SessionWrapper()
    >>> session['a-key'] = 'other value'
    # to clear the attribute, simply:
    >>> del session['a-key']
    
    """
    user = property(lambda self: self.get("umit_user"))

    def __init__(self, sessid=None):
        self.id = None
        self.modified = False
        self.destroyed = False
        if sessid is None:
            self._session = SessionData(self.get_new_sessid())
        else:
            self._session = SessionData.get(sessid)
            if self._session is None:
                self._session = SessionData(sessid)
                self.modified = True

    def get_new_sessid(self):
        """Generates a new session ID."""
        junk = "çoa^wer098~73°0£24q¢ßðæ3w4w98948512397&*@#$!@#*()"
        return md5.new(str(random.randint(0, sys.maxint-1)) \
                                  + str(random.randint(1, sys.maxint-1)//2) \
                                  + junk).hexdigest()

    def get_sessid(self):
        """Return the ID of the session"""
        return self._session.id

    def __setitem__(self, name, value):
        self._session.pickled_data[name] = value
        self.modified = True

    def __getitem__(self, name):
        return self._session.pickled_data[name]

    def __delitem__(self, name):
        del self._session.pickled_data[name]
        self.modified = True

    def keys(self):
        return self._session.pickled_data.keys()

    def has_key(self, key):
        return self._session.pickled_data.has_key(key)

    def items(self):
        return self._session.pickled_data.items()

    def get(self, name, default=None):
        return self._session.pickled_data.get(name, default)

    def save(self):
        self._session.save()

    def destroy(self):
        """Destroy the current session."""
        self._session.delete()
        self._session = None
        self.modified = False
        self.destroyed = True

    @classmethod
    def clear(self):
        """Class method to clear all data in the database."""
        sessions = SessionData.get_list()
        if sessions:
            for session in sessions:
                session.delete()
示例#6
0
 def clear(self):
     """Class method to clear all data in the database."""
     sessions = SessionData.get_list()
     if sessions:
         for session in sessions:
             session.delete()