mirror of
https://github.com/jazzband/django-ddp.git
synced 2026-05-04 21:54:52 +00:00
Stop running request middleware upon connection.
This change deserves a more thorough explanation. All currently released versions of Django are based around the concept of receiving a request and immediately dispatching a response. WebSocket connections don't follow this convention, and the `request` hangs around for long periods of time. As such, things like `request.user` don't really make sense as a user may login, then logout, then login again all within the life of a single request. Given that the concepts applied in Django are based upon a premise that doesn't hold true for WebSockets (that a request is short-lived), it doesn't make sense to apply those concepts in django-ddp.
This commit is contained in:
parent
d358ce413a
commit
e7b38b89db
1 changed files with 1 additions and 12 deletions
|
|
@ -107,7 +107,6 @@ class DDPWebSocketApplication(geventwebsocket.WebSocketApplication):
|
|||
support = None
|
||||
connection = None
|
||||
subs = None
|
||||
request = None
|
||||
remote_ids = None
|
||||
base_handler = BaseHandler()
|
||||
|
||||
|
|
@ -312,21 +311,11 @@ class DDPWebSocketApplication(geventwebsocket.WebSocketApplication):
|
|||
elif version not in support:
|
||||
self.error('Client version/support mismatch.')
|
||||
else:
|
||||
self.request = WSGIRequest(self.ws.environ)
|
||||
# Apply request middleware (so we get request.user and other attrs)
|
||||
# pylint: disable=protected-access
|
||||
if self.base_handler._request_middleware is None:
|
||||
self.base_handler.load_middleware()
|
||||
for middleware_method in self.base_handler._request_middleware:
|
||||
response = middleware_method(self.request)
|
||||
if response:
|
||||
raise ValueError(response)
|
||||
this.request = WSGIRequest(self.ws.environ)
|
||||
this.ws = self
|
||||
this.request = self.request
|
||||
this.send = self.send
|
||||
this.reply = self.reply
|
||||
this.error = self.error
|
||||
this.request.session.save()
|
||||
|
||||
from dddp.models import Connection
|
||||
cur = connection.cursor()
|
||||
|
|
|
|||
Loading…
Reference in a new issue