diff --git a/dddp/migrations/0006_auto_20150428_2245.py b/dddp/migrations/0006_auto_20150428_2245.py new file mode 100644 index 0000000..d579c7a --- /dev/null +++ b/dddp/migrations/0006_auto_20150428_2245.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('dddp', '0005_auto_20150427_1209'), + ] + + operations = [ + migrations.AlterUniqueTogether( + name='connection', + unique_together=set([]), + ), + migrations.RemoveField( + model_name='connection', + name='session', + ), + ] diff --git a/dddp/models.py b/dddp/models.py index 8559ad7..16ed19a 100644 --- a/dddp/models.py +++ b/dddp/models.py @@ -105,24 +105,14 @@ class Connection(models.Model, object): """Django DDP connection instance.""" - session = models.ForeignKey('sessions.Session') connection_id = AleaIdField() server_addr = models.CharField(max_length=255) remote_addr = models.CharField(max_length=255) version = models.CharField(max_length=255) - class Meta(object): - - """Connection model meta.""" - - unique_together = [ - ['connection_id', 'session'], - ] - def __str__(self): """Text representation of subscription.""" - return u'%s/\u200b%s/\u200b%s' % ( - self.session_id, + return u'%s/\u200b%s' % ( self.connection_id, self.remote_addr, ) @@ -131,7 +121,7 @@ class Connection(models.Model, object): @python_2_unicode_compatible class Subscription(models.Model, object): - """Session subscription to a publication with params.""" + """Subscription to a publication with params.""" _publication_cache = {} connection = models.ForeignKey(Connection) diff --git a/dddp/websocket.py b/dddp/websocket.py index 2f25385..d80080d 100644 --- a/dddp/websocket.py +++ b/dddp/websocket.py @@ -145,7 +145,6 @@ class DDPWebSocketApplication(geventwebsocket.WebSocketApplication): self.connection = None self.logger.info('- %s %s', self, reason or 'CLOSE') - @transaction.atomic def on_message(self, message): """Process a message received from remote.""" if self.ws.closed: @@ -192,6 +191,7 @@ class DDPWebSocketApplication(geventwebsocket.WebSocketApplication): except MeteorError, err: self.error(err) + @transaction.atomic def dispatch(self, msg, kwargs): """Dispatch msg to appropriate recv_foo handler.""" # enforce calling 'connect' first @@ -280,7 +280,6 @@ class DDPWebSocketApplication(geventwebsocket.WebSocketApplication): this.version = version this.support = support self.connection = Connection.objects.create( - session_id=this.request.session.session_key, server_addr='%d:%s' % ( backend_pid, self.ws.handler.socket.getsockname(),