

def register_callback(self, public_name, callback, response_class=None, args_extra=None):
    "Registers the specified callback function with the given name.\n\n        Example::\n\n            def handler(obj_response):\n                pass\n\n            # Exposing the same function by 2 different names\n            instance.register_callback('test', handler)\n            instance.register_callback('test2', handler)\n\n        The optional ``response_class`` parameter could be used to substitute the\n        :class:`sijax.response.BaseResponse` class used by default.\n        An instance of ``response_class`` is passed automatically\n        as a first parameter to your response function (``obj_response``).\n\n        Example::\n\n            def handler(obj_response):\n                pass\n\n            class MyResponse(sijax.response.BaseResponse):\n                pass\n\n            # `obj_response` passed to `handler` will be an instance of MyResponse\n            instance.register_callback('test', handler, response_class=MyResponse)\n\n        The optional ``args_extra`` parameter allows you to pass a list of\n        extra arguments to your response function, immediately after\n        the ``obj_response`` argument and before the other call arguments.\n\n        Example::\n\n            def handler(obj_response, arg1, arg2, arg3):\n                # arg1 = 'arg1'\n                # arg2 = 'arg2'\n                # arg3 - expected to come from the browser\n                pass\n\n            instance.register_callback('test', handler, args_extra=['arg1', 'arg2'])\n\n        :param public_name: the name with which this function will be\n                            exposed in the browser\n        :param callback: the actual function to call\n        :param response_class: the response class, an instance of which to use\n                               instead of :class:`sijax.response.BaseResponse`\n        :param args_extra: an optional list of additional arguments to pass\n                           after the response object argument and before the\n                           other call arguments\n        "
    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 = []
    elif 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