MCPcopy Index your code
hub / github.com/pyload/pyload / SessionMiddleware

Class SessionMiddleware

module/lib/beaker/middleware.py:76–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75
76class SessionMiddleware(object):
77 session = beaker_session
78
79 def __init__(self, wrap_app, config=None, environ_key='beaker.session',
80 **kwargs):
81 """Initialize the Session Middleware
82
83 The Session middleware will make a lazy session instance
84 available every request under the ``environ['beaker.session']``
85 key by default. The location in environ can be changed by
86 setting ``environ_key``.
87
88 ``config``
89 dict All settings should be prefixed by 'session.'. This
90 method of passing variables is intended for Paste and other
91 setups that accumulate multiple component settings in a
92 single dictionary. If config contains *no cache. prefixed
93 args*, then *all* of the config options will be used to
94 intialize the Cache objects.
95
96 ``environ_key``
97 Location where the Session instance will keyed in the WSGI
98 environ
99
100 ``**kwargs``
101 All keyword arguments are assumed to be session settings and
102 will override any settings found in ``config``
103
104 """
105 config = config or {}
106
107 # Load up the default params
108 self.options = dict(invalidate_corrupt=True, type=None,
109 data_dir=None, key='beaker.session.id',
110 timeout=None, secret=None, log_file=None)
111
112 # Pull out any config args meant for beaker session. if there are any
113 for dct in [config, kwargs]:
114 for key, val in dct.iteritems():
115 if key.startswith('beaker.session.'):
116 self.options[key[15:]] = val
117 if key.startswith('session.'):
118 self.options[key[8:]] = val
119 if key.startswith('session_'):
120 warnings.warn('Session options should start with session. '
121 'instead of session_.', DeprecationWarning, 2)
122 self.options[key[8:]] = val
123
124 # Coerce and validate session params
125 coerce_session_params(self.options)
126
127 # Assume all keys are intended for cache if none are prefixed with
128 # 'cache.'
129 if not self.options and config:
130 self.options = config
131
132 self.options.update(kwargs)
133 self.wrap_app = wrap_app

Callers 3

webinterface.pyFile · 0.90
filterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected