Skip to content
Myr

only open session if request hasn't been pushed yet

Before adoption: this commit came in with the history the project adopted, so no landing records it.

closes #1348

authored by David Lord · committed by David Lord · parent 5978a0f · Browse files · 2 files+15 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+15 added−8 removed

  • other:+15 added−8 removed

2 files+15 added−8 removed

modified:flask/ctx.py+11 added-8 removed
323 unmodified lines
324 sys.exc_clear()325326 _request_ctx_stack.push(self)327328 # Open the session at the moment that the request context is329 # available. This allows a custom open_session method to use the330 # request context (e.g. code that access database information331 # stored on `g` instead of the appcontext).332 session_interface = self.app.session_interface333 self.session = session_interface.open_session(self.app, self.request)334328 # Open the session at the moment that the request context is available.329 # This allows a custom open_session method to use the request context.330 # Only open a new session if this is the first time the request was331 # pushed, otherwise stream_with_context loses the session.332 if self.session is None:336 self.session = session_interface.make_null_session(self.app)333 session_interface = self.app.session_interface334 self.session = session_interface.open_session(335 self.app, self.request336 )337338 if self.session is None:339 self.session = session_interface.make_null_session(self.app)340341 def pop(self, exc=_sentinel):342 """Pops the request context and unbinds it by doing that. This will343 also trigger the execution of functions registered by the344 :meth:`~flask.Flask.teardown_request` decorator.
71 unmodified lines
modified:CHANGES+4 added
65 unmodified lines
66 ``BadRequestKeyError`` has a message with the bad key in debug mode instead67 of the generic bad request message. (`#2348`_)68- Allow registering new tags with ``TaggedJSONSerializer`` to support69 storing other types in the session cookie. (`#2352`_)70- Only open the session if the request has not been pushed onto the context71 stack yet. This allows ``stream_with_context`` generators to access the same72 session that the containing view uses. (`#2354`_)7374.. _#1489: https://github.com/pallets/flask/pull/148975.. _#1621: https://github.com/pallets/flask/pull/162176.. _#1898: https://github.com/pallets/flask/pull/1898
12 unmodified lines
89.. _#2319: https://github.com/pallets/flask/pull/231990.. _#2326: https://github.com/pallets/flask/pull/232691.. _#2348: https://github.com/pallets/flask/pull/234892.. _#2352: https://github.com/pallets/flask/pull/235293.. _#2354: https://github.com/pallets/flask/pull/23549495Version 0.12.296--------------97
617 unmodified lines