예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
파일: document.py 프로젝트: Jessime/bokeh
    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)
예제 #4
0
            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")
예제 #5
0
            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
예제 #7
0
파일: function.py 프로젝트: alamont/bokeh
    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
예제 #8
0
파일: function.py 프로젝트: rbtr/bokeh
 def __init__(self, func):
     super(FunctionHandler, self).__init__()
     _check_callback(func, ('doc',))
     self._func = func
예제 #9
0
파일: function.py 프로젝트: yihongfa/bokeh
 def __init__(self, func):
     super(FunctionHandler, self).__init__()
     _check_callback(func, ('doc', ))
     self._func = func