Delegate a rule to another class which instantiates a Klein app

    This also memoizes the resource instance on the handler function itself
355466
def enter(clsQname):
    
    def wrapper(routeHandler):
        @functools.wraps(routeHandler)
        def inner(self, request, *a, **kw):
            if getattr(inner, '_subKlein', None) is None:
                cls = namedAny(clsQname)
                inner._subKlein = cls().app.resource()
            return routeHandler(self, request, inner._subKlein, *a, **kw)
        inner._subKleinQname = clsQname
        return inner
    return wrapper
167561
function(args, callInstance) {
    handlers.afterFunc({name: callInstance.name}, null, args, callInstance);
  }
791715
def method_missing(method, *args, &block)
      if _resource.respond_to?(method.to_s)
        result = _resource.send(method, *args, &block)
        result.nil? ? delegate_method(method, *args, &block) : result
      else
        super
      end
    end
15935
def delegate(self, fn, *args, **kwargs):
        """"""
        callback = functools.partial(fn, *args, **kwargs)
        coro = self.loop.run_in_executor(self.subexecutor, callback)
        return asyncio.ensure_future(coro)
827434
def _method(self, *args, **kwargs):
    
    yield self.resource_handler.handle(self.__resource_view_type__, *args, **kwargs)
261158
function (Handler, name) {
        if (!_.isFunction(Handler.init)) {
            throw new Error('The handler for "' + name + '" does not have an "init" function, which is necessary');
        }

        if (!_.isFunction(Handler.pre)) {
            throw new Error('The handler for "' + name + '" does not have a "pre" function, which is necessary');
        }

        if (!_.isFunction(Handler.post)) {
            throw new Error('The handler for "' + name + '" does not have a "post" function, which is necessary');
        }

        if (!_.isFunction(Handler.sign)) {
            throw new Error('The handler for "' + name + '" does not have a "sign" function, which is necessary');
        }

        Object.defineProperty(Handler, AUTH_TYPE_PROP, {
            value: name,
            configurable: false,
            enumerable: false,
            writable: false
        });

        AuthLoader.handlers[name] = Handler;
    }
573895
function (callback) {
      this.recognizer.delegate = this.delegate;

      this.recognizer.map(callback, function (recognizer, routes) {
        for (var i = routes.length - 1, proceed = true; i >= 0 && proceed; --i) {
          var route = routes[i];
          recognizer.add(routes, { as: route.handler });
          proceed = route.path === '/' || route.path === '' || route.handler.slice(-6) === '.index';
        }
      });
    }
975940
def add_handler(self, f):
        
        if f.__name__.startswith('rpc_'):
            raise ValueError("Server method names cannot start with rpc_.")
        self._json_rpc_methods[f.__name__] = f
        return f
372199
def add_rule(self, name, callable_):
        """"""
        assert isinstance(name, basestring)
        assert callable(callable_)
        self.project_rules_.add_rule(name, callable_)
775574
def wrap(self, starter_cls):
        
        if isinstance(starter_cls, type) and issubclass(starter_cls, ProcessStarter):
            return starter_cls
        depr_msg = 'Pass a ProcessStarter for preparefunc'
        warnings.warn(depr_msg, DeprecationWarning, stacklevel=3)
        return functools.partial(CompatStarter, starter_cls)
1109373
function initDomHandler(instance) {
    zrUtil.each(touchHandlerNames, function (name) {
        instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
    });

    zrUtil.each(pointerHandlerNames, function (name) {
        instance._handlers[name] = zrUtil.bind(domHandlers[name], instance);
    });

    zrUtil.each(mouseHandlerNames, function (name) {
        instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
    });

    function makeMouseHandler(fn, instance) {
        return function () {
            if (instance._touching) {
                return;
            }
            return fn.apply(instance, arguments);
        };
    }
}
177360
function Call(path) {
  if (typeof path !== 'string' || arguments.length > 1) { throw new Error('Property decorators can be used for single property access') }
  return createDecorator((options, key) => {
    if (!options.methods) options.methods = {}
    options.methods[key] = call(path)
  })
}
1058923
def bind(self, instance, auto=False):
        
        methods = [
            (m, cls.__dict__[m])
            for cls in inspect.getmro(type(instance))
            for m in cls.__dict__ if inspect.isfunction(cls.__dict__[m])
            ]

        try:
            deps_of_endpoints = [(method_ptr, self.entrypoint_deps(method_ptr))
                                 for (method_name, method_ptr) in methods]

            for (method_ptr, method_deps) in deps_of_endpoints:
                if len(method_deps) > 0:
                    method_ptr(instance, **method_deps)
        except KeyError:
            pass

        if auto and instance not in self.current_scope.get_auto_bind_list():
            self.current_scope.auto_bind(instance)

        return instance
1071622
def bind(cls, app, *paths, methods=None, name=None, **kwargs):
        
        paths = paths or ['/%s(/{%s})?/?' % (cls.name, cls.name)]
        name = name or "api.%s" % cls.name
        return super(RESTHandler, cls).bind(app, *paths, methods=methods, name=name, **kwargs)
463053
def bind(self, func, etype):
        '''
        
        '''
        if func not in self._event_cbs:
            wrapped = self._WrapCB(self, func)
            self._event_cbs[func] = wrapped
        else:
            wrapped = self._event_cbs[func]
        self.container.bind(wrapped, etype)
1051275
function runHandler(plugin, handler, cancel) {
  return function runHandlerDelegate(data) {
    if (!data) {
      return Promise.resolve();
    }

    return Promise
      .resolve(handler.handler(data, plugin, cancel))
      .then(function(result) {
        return data.configure(result);
      });
  };
}
945255
def init_app(cls, app, callback=None):
        
        processed = set()
        cls.__views__ = set()
        cls.is_always_available = False
        for base in cls.__mro__:
            for name, attr in base.__dict__.items():
                if name in processed:
                    continue
                processed.add(name)
                if isinstance(attr, ViewHandler):
                    if base != cls:  # Copy ViewHandler instances into subclasses
                        # TODO: Don't do this during init_app. Use a metaclass
                        # and do this when the class is defined.
                        attr = attr.copy_for_subclass()
                        setattr(cls, name, attr)
                    attr.__set_name__(cls, name)  # Required for Python < 3.6
                    cls.__views__.add(name)
                    attr.init_app(app, cls, callback=callback)
                    if not hasattr(attr.wrapped_func, 'is_available'):
                        cls.is_always_available = True