Allows adding a webhook_handler as an alternative to the decorators
512051
def set_webhook_handler(self, scope, callback):
        
        scope = scope.lower()

        if scope == 'after_send':
            self._after_send = callback
            return

        if scope not in Page.WEBHOOK_ENDPOINTS:
            raise ValueError("The 'scope' argument must be one of {}.".format(Page.WEBHOOK_ENDPOINTS))

        self._webhook_handlers[scope] = callback
611976
def register_postloop_hook(self, func: Callable[[None], None]) -> None:
        """"""
        self._validate_prepostloop_callable(func)
        self._postloop_hooks.append(func)
894153
def webhook_handler(request):
    
    body = request.stream.read().decode('utf8')
    print('webhook handler saw:', body)
    api.notify_webhook_received(payload=body)

    # nb. protected references are not part of the API.
    # this is just to demonstrate that the asyncid is stored
    print('key store contains:', api._db.keys())
429222
function injectHook(options, name, hook) {
  const existing = options[name]
  options[name] = existing
    ? Array.isArray(existing) ? existing.concat(hook) : [existing, hook]
    : [hook]
}
649897
def respond_webhook(self, environ):
        
        request = FieldStorage(fp=environ["wsgi.input"], environ=environ)
        url = environ["PATH_INFO"]
        params = dict([(k, request[k].value) for k in request])
        try:
            if self.bot is None:
                raise NotImplementedError
            response = self.bot.handle_webhook_event(environ, url, params)
        except NotImplementedError:
            return 404
        except:
            self.logger.debug(format_exc())
            return 500
        return response or 200
544906
def statichttp(container = None):
    ""
    def decorator(func):
        @functools.wraps(func)
        def handler(event):
            return _handler(container, event, func)
        if hasattr(func, '__self__'):
            handler.__self__ = func.__self__
        return handler
    return decorator
800889
def web_hook_receiver(sender, **kwargs):
    """"""

    deployment = Deployment.objects.get(pk=kwargs.get('deployment_id'))

    hooks = deployment.web_hooks

    if not hooks:
        return

    for hook in hooks:

        data = payload_generator(deployment)

        deliver_hook(deployment, hook.url, data)
1195415
def _handler(func):
    ""

    def _wrapped(*a, **k):
        r = func(*a, **k)
        if r is None: r = 0
        return r

    return staticmethod(_wrapped)
84651
def hook_decorator(cb_type):
    
    def decorator_wrapper(*tags_or_func):
        if len(tags_or_func) == 1 and callable(tags_or_func[0]):
            # No tags were passed to this decorator
            func = tags_or_func[0]
            return HookImpl(cb_type, func)
        else:
            # We got some tags, so we need to produce the real decorator
            tags = tags_or_func
            def d(func):
                return HookImpl(cb_type, func, tags)
            return d
    return decorator_wrapper
755424
def getHook(self, repo_user, repo_name, hook_id):
        
        return self.api.makeRequest(
            ['repos', repo_user, repo_name, 'hooks', str(hook_id)],
            method='GET',
            )
862373
function runHook (instance, type) {
  var hook = type ? 'response' : 'request'
  hook += 'Hook'
  if (instance[hook] && isFunction(instance[hook])) {
    instance[hook]()
  }
}
50686
def trigger_hook(self, name, *args, **kwargs):
        """"""
        method = getattr(self, name, None)
        if is_callable(method):
            method(*args, **kwargs)
            
        try:
            children = self.children
        except AttributeError:
            return
        else:
            if children is not None:
                for child in children:
                    method = getattr(child, 'trigger_hook', None)
                    if is_callable(method):
                        method(name, *args, **kwargs)
                    else:
                        method = getattr(child, name, None)
                        if is_callable(method):
                            method(*args, **kwargs)
410999
async def hook(self, *args, **kwargs):
        

        return await self._makeApiCall(self.funcinfo["hook"], *args, **kwargs)
1350712
def set_webhook(self, *args, **kwargs):
        """"""
        return set_webhook(*args, **self._merge_overrides(**kwargs)).run()
640954
def trigger_hook(self, __name, *args, **kwargs):
        '''  '''
        return [hook(*args, **kwargs) for hook in self._hooks[__name][:]]
971104
def post_run_hook(self, func, prefix=None):
        
        cf = self.capture(func, prefix=prefix)
        self.post_run_hooks.append(cf)
        return cf
454606
def add_handler(self, handler):
        """"""
        if not callable(handler):
            raise TypeError("'%s' is not callable." % handler)

        self.append(handler)