diff --git a/panel/pane/base.py b/panel/pane/base.py index 8814ab7dcc..846a3c2656 100644 --- a/panel/pane/base.py +++ b/panel/pane/base.py @@ -235,7 +235,7 @@ def clone(self, object=None, **params): object = old_object return type(self)(object, **params) - def get_root(self, doc=None, comm=None): + def get_root(self, doc=None, comm=None, preprocess=True): """ Returns the root model and applies pre-processing hooks @@ -245,6 +245,8 @@ def get_root(self, doc=None, comm=None): Bokeh document the bokeh model will be attached to. comm: pyviz_comms.Comm Optional pyviz_comms when working in notebook + preprocess: boolean (default=True) + Whether to run preprocessing hooks Returns ------- @@ -255,7 +257,8 @@ def get_root(self, doc=None, comm=None): root = self._get_model(doc, comm=comm) else: root = self.layout._get_model(doc, comm=comm) - self._preprocess(root) + if preprocess: + self._preprocess(root) ref = root.ref['id'] state._views[ref] = (self, root, doc, comm) return root diff --git a/panel/param.py b/panel/param.py index c059154cef..6f922fbdd3 100644 --- a/panel/param.py +++ b/panel/param.py @@ -580,7 +580,7 @@ def select(self, selector=None): """ return super().select(selector) + self.layout.select(selector) - def get_root(self, doc=None, comm=None): + def get_root(self, doc=None, comm=None, preprocess=True): """ Returns the root model and applies pre-processing hooks @@ -590,13 +590,15 @@ def get_root(self, doc=None, comm=None): Bokeh document the bokeh model will be attached to. comm: pyviz_comms.Comm Optional pyviz_comms when working in notebook + preprocess: boolean (default=True) + Whether to run preprocessing hooks Returns ------- Returns the bokeh model corresponding to this panel object """ doc = init_doc(doc) - root = self.layout.get_root(doc, comm) + root = self.layout.get_root(doc, comm, preprocess) ref = root.ref['id'] self._models[ref] = (root, None) state._views[ref] = (self, root, doc, comm) diff --git a/panel/template/base.py b/panel/template/base.py index bdd25fb3b5..a1dddd988d 100644 --- a/panel/template/base.py +++ b/panel/template/base.py @@ -146,7 +146,7 @@ def _init_doc(self, doc=None, comm=None, title=None, notebook=False, location=Tr for name, (obj, tags) in self._render_items.items(): if self._apply_hooks not in obj._hooks: obj._hooks.append(self._apply_hooks) - model = obj.get_root(doc, comm) + model = obj.get_root(doc, comm, preprocess=False) mref = model.ref['id'] doc.on_session_destroyed(obj._server_destroy) for sub in obj.select(Viewable): diff --git a/panel/viewable.py b/panel/viewable.py index 3e0b29ff8e..a3a306eea5 100644 --- a/panel/viewable.py +++ b/panel/viewable.py @@ -461,7 +461,7 @@ def _server_destroy(self, session_context): loc._cleanup(root) del state._locations[doc] - def get_root(self, doc=None, comm=None): + def get_root(self, doc=None, comm=None, preprocess=True): """ Returns the root model and applies pre-processing hooks @@ -471,6 +471,8 @@ def get_root(self, doc=None, comm=None): Bokeh document the bokeh model will be attached to. comm: pyviz_comms.Comm Optional pyviz_comms when working in notebook + preprocess: boolean (default=True) + Whether to run preprocessing hooks Returns ------- @@ -478,7 +480,8 @@ def get_root(self, doc=None, comm=None): """ doc = init_doc(doc) root = self._get_model(doc, comm=comm) - self._preprocess(root) + if preprocess: + self._preprocess(root) ref = root.ref['id'] state._views[ref] = (self, root, doc, comm) return root