Skip to content

Commit

Permalink
Various fixes for resolution of links (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Apr 2, 2019
1 parent 8ab6a57 commit 7bf4b9f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion panel/io/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def curdoc(self, doc):

@property
def session_args(self):
return self.curdoc.session_context.arguments if self.curdoc else {}
return self.curdoc.session_context.request.arguments if self.curdoc else {}


state = _state()
6 changes: 5 additions & 1 deletion panel/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ def _update_model(self, events, msg, root, model, doc, comm=None):
old = events['objects'].old
msg[self._rename['objects']] = self._get_objects(model, old, doc, root, comm)
model.update(**msg)
self._preprocess(root) #preprocess links between new elements

from .io import state
ref = root.ref['id']
if ref in state._views:
state._views[ref][0]._preprocess(root)

#----------------------------------------------------------------
# Model API
Expand Down
6 changes: 5 additions & 1 deletion panel/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def _init_callback(self, root_model, link, source, src_spec, target, tgt_spec, c
if k not in ('source', 'target', 'name', 'code')}

src_model = self._resolve_model(root_model, source, src_spec[0])
link_id = id(link)
if any(link_id in cb.tags for cbs in src_model.js_property_callbacks.values() for cb in cbs):
# Skip registering callback if already registered
return
references['source'] = src_model

tgt_model = self._resolve_model(root_model, target, tgt_spec[0])
Expand All @@ -226,7 +230,7 @@ def _init_callback(self, root_model, link, source, src_spec, target, tgt_spec, c
if code is None:
code = self._get_code(link, source, src_spec[1], target, tgt_spec[1])

src_cb = CustomJS(args=references, code=code)
src_cb = CustomJS(args=references, code=code, tags=[link_id])
changes, events = self._get_triggers(link, src_spec)
for ch in changes:
src_model.js_on_change(ch, src_cb)
Expand Down
19 changes: 19 additions & 0 deletions panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,25 @@ def _get_model(self, doc, root=None, parent=None, comm=None):
self._models[ref] = (model, parent)
return model

def select(self, selector=None):
"""
Iterates over the Viewable and any potential children in the
applying the Selector.
Arguments
---------
selector: type or callable or None
The selector allows selecting a subset of Viewables by
declaring a type or callable function to filter by.
Returns
-------
viewables: list(Viewable)
"""
selected = super(ParamMethod, self).select(selector)
selected += self._pane.select(selector)
return selected

def _cleanup(self, root=None):
self._inner_layout._cleanup(root)
super(ParamMethod, self)._cleanup(root)
Expand Down

0 comments on commit 7bf4b9f

Please sign in to comment.