def __init__(self, *args, **kwargs): super(CustomHandler, self).__init__(*args, **kwargs) if 'callback_function' not in kwargs: raise ValueError('Must pass a callback_function to CustomHandler') func = kwargs['callback_function'] _check_callback(func, ('doc', )) print(kwargs) # the function that needs to be excecuted to create the document self._func = func self._safe_to_fork = True # setup the template self._template = None template_path = kwargs.get('template_path', None) if template_path and exists(template_path): env = Environment(loader=FileSystemLoader(dirname(template_path))) self._template = env.get_template(basename(template_path)) # Setup static self._static = None static_path = kwargs.get('static_path', None) if static_path and exists(static_path): self._static = static_path print(self._static) print(self._template)
def on_change(self, *callbacks): ''' Invoke callback if the document or any Model reachable from its roots changes. ''' for callback in callbacks: if callback in self._callbacks: continue _check_callback(callback, ('event', )) self._callbacks.append(callback)
def on_change(self, *callbacks): ''' Invoke callback if the document or any Model reachable from its roots changes. ''' for callback in callbacks: if callback in self._callbacks: continue _check_callback(callback, ('event',)) self._callbacks.append(callback)
def extract_callbacks(): contents = self._module.__dict__ if 'on_server_loaded' in contents: self._on_server_loaded = contents['on_server_loaded'] if 'on_server_unloaded' in contents: self._on_server_unloaded = contents['on_server_unloaded'] if 'on_session_created' in contents: self._on_session_created = contents['on_session_created'] if 'on_session_destroyed' in contents: self._on_session_destroyed = contents['on_session_destroyed'] _check_callback(self._on_server_loaded, ('server_context',), what="on_server_loaded") _check_callback(self._on_server_unloaded, ('server_context',), what="on_server_unloaded") _check_callback(self._on_session_created, ('session_context',), what="on_session_created") _check_callback(self._on_session_destroyed, ('session_context',), what="on_session_destroyed")
def __init__(self, func): ''' Args: func (callable) : a function to modify and return a Bokeh Document. The function should have the form: .. code-block:: python def func(doc): # modify doc return doc and it should return the passed-in document after making any modifications in-place. ''' super(FunctionHandler, self).__init__() _check_callback(func, ('doc', )) self._func = func self._safe_to_fork = True
def __init__(self, func): ''' Args: func (callable) : a function to modify and return a Bokeh Document. The function should have the form: .. code-block:: python def func(doc): # modify doc return doc and it should return the passed-in document after making any modifications in-place. ''' super(FunctionHandler, self).__init__() _check_callback(func, ('doc',)) self._func = func self._safe_to_fork = True
def __init__(self, func): super(FunctionHandler, self).__init__() _check_callback(func, ('doc',)) self._func = func
def __init__(self, func): super(FunctionHandler, self).__init__() _check_callback(func, ('doc', )) self._func = func