Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ documentation), the following configuration settings are available:
``SESSION_SET_TTL`` Whether or not to set the time-to-live of the
session on the backend, if supported. Default
is ``True``.
``SESSION_PICKLE_PROTOCOL`` The Pickling protocol to be used when storing
the session on the backend. Default is set to
the pickle module DEFAULT_PROTOCOL.
============================== ================================================


Expand Down
7 changes: 6 additions & 1 deletion flask_kvsession/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ def save_session(self, app, session, response):
app.config['SESSION_KEY_BITS'])).serialize()

# save the session, now its no longer new (or modified)
data = self.serialization_method.dumps(dict(session))
if 'SESSION_PICKLE_PROTOCOL' in current_app.config:
# A Pickle Protocol was specified in the Flask app configuration so we will attempt to respect it.
data = self.serialization_method.dumps(dict(session),
protocol=current_app.config['SESSION_PICKLE_PROTOCOL'])
else:
data = self.serialization_method.dumps(dict(session))
store = current_app.kvsession_store

if getattr(store, 'ttl_support', False):
Expand Down