diff --git a/object_database/web/ActiveWebService.py b/object_database/web/ActiveWebService.py index a2459001..e0dd358b 100644 --- a/object_database/web/ActiveWebService.py +++ b/object_database/web/ActiveWebService.py @@ -102,7 +102,14 @@ def __init__(self, db, serviceObject, serviceRuntimeConfig): self._logger = logging.getLogger(__name__) @staticmethod - def configure(db, serviceObject, hostname, port, level_name="INFO"): + def configure( + db, + serviceObject, + hostname, + port, + level_name="INFO", + primaryDisplayServiceName=None + ): db.subscribeToType(Configuration) with db.transaction(): @@ -113,6 +120,7 @@ def configure(db, serviceObject, hostname, port, level_name="INFO"): c.hostname = hostname c.port = port c.log_level = logging.getLevelName(level_name) + c.primaryDisplayServiceName = primaryDisplayServiceName @staticmethod def setLoginPlugin( diff --git a/object_database/web/ActiveWebService_util.py b/object_database/web/ActiveWebService_util.py index 8e140c4d..678dab47 100644 --- a/object_database/web/ActiveWebService_util.py +++ b/object_database/web/ActiveWebService_util.py @@ -73,6 +73,9 @@ class Session: class Configuration: service = Indexed(service_schema.Service) + # if not None, then this is the only service display we're allowed to use + primaryDisplayServiceName = OneOf(None, str) + port = int hostname = str @@ -352,6 +355,8 @@ def displayAndHeadersForPathAndQueryArgs(path, queryArgs): to the schema of the typeObj (c.f., call to cells.ensureSubscribedSchema) """ + if not len(path): + path = ['services'] if len(path) and path[0] == "services": if len(path) == 1: # 'services' display diff --git a/object_database/web/CellsSession.py b/object_database/web/CellsSession.py index 9f855fe5..7ba5c442 100644 --- a/object_database/web/CellsSession.py +++ b/object_database/web/CellsSession.py @@ -24,6 +24,7 @@ from object_database.web.ActiveWebService_util import ( makeMainView, displayAndHeadersForPathAndQueryArgs, + Configuration ) from object_database.web.cells import Subscribed, Cells, MAX_FPS, SessionState @@ -344,6 +345,17 @@ def run(self): self.cells.cleanupCells() def displayForPathAndQueryArgs(self, path, queryArgs): + config = Configuration.lookupAll(service=self.session.executingInstance.service) + + if config and config[0].primaryDisplayServiceName is not None: + # pretend as if 'services/{primaryDisplayService.name}' are at the front + # of the path. This prevents us from reaching any other services internally, + # also doesn't screw with path routing internally + prefix = ['services', config[0].primaryDisplayServiceName] + + if path[:2] != prefix: + path = prefix + list(path) + try: display, toggles = displayAndHeadersForPathAndQueryArgs(path, queryArgs)