def register_callback(self, public_name, callback, response_class=None,
                          args_extra=None):
        """Registers the specified callback function with the given name.

        Example::

            def handler(obj_response):
                pass

            # Exposing the same function by 2 different names
            instance.register_callback('test', handler)
            instance.register_callback('test2', handler)

        The optional ``response_class`` parameter could be used to substitute the
        :class:`sijax.response.BaseResponse` class used by default.
        An instance of ``response_class`` is passed automatically
        as a first parameter to your response function (``obj_response``).

        Example::

            def handler(obj_response):
                pass

            class MyResponse(sijax.response.BaseResponse):
                pass

            # `obj_response` passed to `handler` will be an instance of MyResponse
            instance.register_callback('test', handler, response_class=MyResponse)

        The optional ``args_extra`` parameter allows you to pass a list of
        extra arguments to your response function, immediately after
        the ``obj_response`` argument and before the other call arguments.

        Example::

            def handler(obj_response, arg1, arg2, arg3):
                # arg1 = 'arg1'
                # arg2 = 'arg2'
                # arg3 - expected to come from the browser
                pass

            instance.register_callback('test', handler, args_extra=['arg1', 'arg2'])

        :param public_name: the name with which this function will be
                            exposed in the browser
        :param callback: the actual function to call
        :param response_class: the response class, an instance of which to use
                               instead of :class:`sijax.response.BaseResponse`
        :param args_extra: an optional list of additional arguments to pass
                           after the response object argument and before the
                           other call arguments
        """
        if response_class is None:
            response_class = BaseResponse
        if not hasattr(response_class, '__call__'):
            raise SijaxError('response_class needs to be a callable!')

        if args_extra is None:
            args_extra = []
        else:
            if isinstance(args_extra, tuple):
                args_extra = list(args_extra)
            elif not isinstance(args_extra, list):
                raise SijaxError('args_extra could only be a tuple or a list!')

        params = {}
        params[self.__class__.PARAM_CALLBACK] = callback
        params[self.__class__.PARAM_RESPONSE_CLASS] = response_class
        params[self.__class__.PARAM_ARGS_EXTRA] = args_extra

        self._callbacks[public_name] = params
        return self
dataset/ETHPy150Open spantaleev/sijax-python/sijax/core.py/Sijax.register_callback/original