diff --git a/openslides/utils/autoupdate.py b/openslides/utils/autoupdate.py index 2992ea3b1..9aa9339cb 100644 --- a/openslides/utils/autoupdate.py +++ b/openslides/utils/autoupdate.py @@ -21,6 +21,9 @@ from tornado.wsgi import WSGIContainer from .rest_api import get_collection_and_id_from_url +RUNNING_PORT = None +RUNNING_HOST = None + class DjangoStaticFileHandler(StaticFileHandler): """ @@ -94,8 +97,9 @@ class OpenSlidesSockJSConnection(SockJSConnection): object_url. """ # Join network location with object URL. - # TODO: Use host and port as given in the start script - wsgi_network_location = settings.OPENSLIDES_WSGI_NETWORK_LOCATION or 'http://localhost:8000' + wsgi_network_location = ( + settings.OPENSLIDES_WSGI_NETWORK_LOCATION or + 'http://{}:{}'.format(RUNNING_HOST, RUNNING_PORT)) url = ''.join((wsgi_network_location, object_url)) # Send out internal HTTP request to get data from the REST api. @@ -127,6 +131,11 @@ def run_tornado(addr, port, *args, **kwargs): It runs in one thread. """ + # Save the port and the addr in a global var + global RUNNING_PORT, RUNNING_HOST + RUNNING_PORT = port + RUNNING_HOST = addr + # Don't try to read the command line args from openslides parse_command_line(args=[]) @@ -147,6 +156,10 @@ def run_tornado(addr, port, *args, **kwargs): server.listen(port=port, address=addr) IOLoop.instance().start() + # reset the global vars + RUNNING_PORT = None + RUNNING_HOST = None + def inform_changed_data(*args): """