fix autoupdate when openslides runs on a other port then 8000

This commit is contained in:
Oskar Hahn 2016-01-10 00:17:00 +01:00
parent c30116f5c1
commit b968a92630

View File

@ -21,6 +21,9 @@ from tornado.wsgi import WSGIContainer
from .rest_api import get_collection_and_id_from_url from .rest_api import get_collection_and_id_from_url
RUNNING_PORT = None
RUNNING_HOST = None
class DjangoStaticFileHandler(StaticFileHandler): class DjangoStaticFileHandler(StaticFileHandler):
""" """
@ -94,8 +97,9 @@ class OpenSlidesSockJSConnection(SockJSConnection):
object_url. object_url.
""" """
# Join network location with object URL. # Join network location with object URL.
# TODO: Use host and port as given in the start script wsgi_network_location = (
wsgi_network_location = settings.OPENSLIDES_WSGI_NETWORK_LOCATION or 'http://localhost:8000' settings.OPENSLIDES_WSGI_NETWORK_LOCATION or
'http://{}:{}'.format(RUNNING_HOST, RUNNING_PORT))
url = ''.join((wsgi_network_location, object_url)) url = ''.join((wsgi_network_location, object_url))
# Send out internal HTTP request to get data from the REST api. # 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. 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 # Don't try to read the command line args from openslides
parse_command_line(args=[]) parse_command_line(args=[])
@ -147,6 +156,10 @@ def run_tornado(addr, port, *args, **kwargs):
server.listen(port=port, address=addr) server.listen(port=port, address=addr)
IOLoop.instance().start() IOLoop.instance().start()
# reset the global vars
RUNNING_PORT = None
RUNNING_HOST = None
def inform_changed_data(*args): def inform_changed_data(*args):
""" """