Beispiel #1
0
#!/usr/bin/env python

from twisted.internet import reactor as txreactor
from twisted.internet import task
from webtest import log

logger = log.get_logger()


def logging_errback(f, label="logging_errback"):
    logger.error("%s: %s" % (label, f.getBriefTraceback()))


class PersistentSessionDict(dict):
    """
    A user's web session data. NOTE: We're subclassing dict. Never do that.

    @ivar uid: A unique identifier for the session, C{bytes}.
    @ivar dictionary: The default session data. Must be a dict. Probably empty.
    @ivar factory: The session factory that creates instances of this class and
        mediates interactions with the persistence mechanism (probably Redis)
    @ivar _reactor: An object providing L{IReactorTime} to use for scheduling
        expiration.
    """

    # Default lifetime for session data in seconds
    defaultSessionTimeout = 900

    def __init__(self,
                 uid,
                 dictionary,
Beispiel #2
0
#!/usr/bin/env python

from twisted.internet import reactor as txreactor
from twisted.internet import task
from webtest import log

logger = log.get_logger()

def logging_errback(f, label="logging_errback"):
    logger.error("%s: %s" % (label, f.getBriefTraceback()))


class PersistentSessionDict(dict):
    """
    A user's web session data. NOTE: We're subclassing dict. Never do that.

    @ivar uid: A unique identifier for the session, C{bytes}.
    @ivar dictionary: The default session data. Must be a dict. Probably empty.
    @ivar factory: The session factory that creates instances of this class and
        mediates interactions with the persistence mechanism (probably Redis)
    @ivar _reactor: An object providing L{IReactorTime} to use for scheduling
        expiration.
    """

    # Default lifetime for session data in seconds
    defaultSessionTimeout = 900

    def __init__(self, uid, dictionary, factory, _reactor=False, session_timeout=None):
        dict.__init__(self, dictionary)
        self._modified = set()
        self._removed = set()