Decorator for views that require a team be supplied wither via a slug in the
    url pattern or already set on the request object from the TeamMiddleware
1859
def team_required(func=None):
    
    def decorator(view_func):
        @functools.wraps(view_func, assigned=available_attrs(view_func))
        def _wrapped_view(request, *args, **kwargs):
            slug = kwargs.pop("slug", None)
            if not getattr(request, "team", None):
                request.team = get_object_or_404(Team, slug=slug)
            return view_func(request, *args, **kwargs)
        return _wrapped_view
    if func:
        return decorator(func)
    return decorator
670602
def need_maintenance_response(request):
    

    try:
        view_match = resolve(request.path)
        view_func = view_match[0]
        view_dict = view_func.__dict__

        view_force_maintenance_mode_off = view_dict.get(
            'force_maintenance_mode_off', False)
        if view_force_maintenance_mode_off:
            # view has 'force_maintenance_mode_off' decorator
            return False

        view_force_maintenance_mode_on = view_dict.get(
            'force_maintenance_mode_on', False)
        if view_force_maintenance_mode_on:
            # view has 'force_maintenance_mode_on' decorator
            return True

    except Resolver404:
        pass

    if not get_maintenance_mode():
        return False

    try:
        url_off = reverse('maintenance_mode_off')

        resolve(url_off)

        if url_off == request.path_info:
            return False

    except NoReverseMatch:
        # maintenance_mode.urls not added
        pass

    if hasattr(request, 'user'):

        if django.VERSION < (1, 10):
            if settings.MAINTENANCE_MODE_IGNORE_ANONYMOUS_USER \
                    and request.user.is_anonymous():
                return False

            if settings.MAINTENANCE_MODE_IGNORE_AUTHENTICATED_USER \
                    and request.user.is_authenticated():
                return False
        else:
            if settings.MAINTENANCE_MODE_IGNORE_ANONYMOUS_USER \
                    and request.user.is_anonymous:
                return False

            if settings.MAINTENANCE_MODE_IGNORE_AUTHENTICATED_USER \
                    and request.user.is_authenticated:
                return False

        if settings.MAINTENANCE_MODE_IGNORE_STAFF \
                and request.user.is_staff:
            return False

        if settings.MAINTENANCE_MODE_IGNORE_SUPERUSER \
                and request.user.is_superuser:
            return False

    if settings.MAINTENANCE_MODE_IGNORE_ADMIN_SITE:

        try:
            request_path = request.path if request.path else ''
            if not request_path.endswith('/'):
                request_path += '/'

            admin_url = reverse('admin:index')
            if request_path.startswith(admin_url):
                return False

        except NoReverseMatch:
            # admin.urls not added
            pass

    if settings.MAINTENANCE_MODE_IGNORE_TESTS:

        is_testing = False

        if (len(sys.argv) > 0 and 'runtests' in sys.argv[0]) \
                or (len(sys.argv) > 1 and sys.argv[1] == 'test'):
            # python runtests.py | python manage.py test | python
            # setup.py test | django-admin.py test
            is_testing = True

        if is_testing:
            return False

    if settings.MAINTENANCE_MODE_IGNORE_IP_ADDRESSES:

        if settings.MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS:
            try:
                get_client_ip_address_func = import_string(
                    settings.MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS)
            except ImportError:
                raise ImproperlyConfigured(
                    'settings.MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS '
                    'is not a valid function path.')
            else:
                client_ip_address = get_client_ip_address_func(request)
        else:
            client_ip_address = get_client_ip_address(request)

        for ip_address in settings.MAINTENANCE_MODE_IGNORE_IP_ADDRESSES:

            ip_address_re = re.compile(ip_address)

            if ip_address_re.match(client_ip_address):
                return False

    if settings.MAINTENANCE_MODE_IGNORE_URLS:

        for url in settings.MAINTENANCE_MODE_IGNORE_URLS:

            if not isinstance(url, pattern_class):
                url = str(url)
            url_re = re.compile(url)

            if url_re.match(request.path_info):
                return False

    if settings.MAINTENANCE_MODE_REDIRECT_URL:

        redirect_url_re = re.compile(
            settings.MAINTENANCE_MODE_REDIRECT_URL)

        if redirect_url_re.match(request.path_info):
            return False

    return True
34055
def decorate(self, view):
		
		from functools import wraps

		@wraps(view)
		def decorated(*args, **kwargs):
			response = view(*args, **kwargs)
			accept = self.get_accept()
			return self.output(response, accept)
		return decorated
503100
def login_required(view):
    """"""

    @functools.wraps(view)
    def wrapped_view(**kwargs):
        if g.user is None:
            return redirect(url_for("auth.login"))

        return view(**kwargs)

    return wrapped_view
89987
def root(self, request, url):
        
        # Delegate to the appropriate method, based on the URL.
        if url is None:
            return self.main_view(request)
        try:
            plugin_name, rest_of_url = url.split('/', 1)
        except ValueError:  # need more than 1 value to unpack
            plugin_name, rest_of_url = url, None
        try:
            plugin = self.plugins[plugin_name]
        except KeyError:
            raise http.Http404('A plugin with the requested name '
                               'does not exist.')
        return plugin.model_view(request, self, rest_of_url)
233153
def expose(url_rule, endpoint=None, **kwargs):
    """"""

    def decorate(f):
        e = endpoint or f.__name__
        endpoints[e] = f
        url_map.add(Rule(url_rule, endpoint=e, **kwargs))
        return f

    return decorate
978817
def dispatch(self):
        
        from flask import request

        method = request.method

        data = request.args
        if method == 'POST':
            data = request.form

        token = data.get('token')
        team_id = data.get('team_id')
        command = data.get('command') or data.get('trigger_word')

        if isinstance(command, string_types):
            command = command.strip().lstrip('/')

        try:
            self.validate(command, token, team_id, method)
        except SlackError as e:
            return self.response(e.msg)

        func, _, _, kwargs = self._commands[(team_id, command)]
        kwargs.update(data.to_dict())

        return func(**kwargs)
945373
def routeargs(path, host = None, vhost = None, method = [b'POST'], **kwargs):
        ""
        def decorator(func):
            func.routemode = 'routeargs'
            func.route_path = path
            func.route_host = host
            func.route_vhost = vhost
            func.route_method = method
            func.route_kwargs = kwargs
            return func
        return decorator
1210622
def as_view(cls, endpoint, protocol, *init_args, **init_kwargs):
        '''
        
        '''
        def _wrapper(request, *args, **kwargs):
            ''' Make a new instance of the resource class and returns a coroutine for execution'''
            instance = cls(*init_args, endpoint=endpoint, request=request, **init_kwargs)
            if protocol == Resource.Protocol.http:
                return instance._wrap_http(cls.dispatch, endpoint=endpoint, *args, **kwargs)
            elif protocol == Resource.Protocol.websocket:
                return instance._wrap_ws(cls.dispatch, endpoint=endpoint, *args, **kwargs)
            elif protocol == Resource.Protocol.amqp:
                return instance._wrap_amqp(endpoint, *args, **kwargs)
            else:
                raise Exception('Communication protocol not specified')

        return _wrapper
1040174
def route(view, endpoint=None, methods=None, defaults=None, **options):
    
    if not endpoint:
        endpoint = view
    if not methods:
        methods = ['GET']
    return dict(
        view_func=LazyView(view),
        endpoint=endpoint,
        methods=methods,
        defaults=defaults,
        **options
    )
192204
function(req, res, next){

  	// Find teams
  	app.models.Team.find().exec(finishRendering);

  	function finishRendering(err, collection){
  		if(err) return next('Failed to retrieve data');

  		return res.render('team/manage', {
  			path: req.route.path,
  			teams: collection
  		});
  	}
  }
327324
def dispatch(self, request, *args, **kwargs):
        
        allowed_methods = self.get_allowed_methods()
        try:
            if request.method == 'GET' and 'GET' in allowed_methods:
                if 'pk' in request.GET or self.slug_field in request.GET:
                    return self.ng_get(request, *args, **kwargs)
                return self.ng_query(request, *args, **kwargs)
            elif request.method == 'POST' and 'POST' in allowed_methods:
                return self.ng_save(request, *args, **kwargs)
            elif request.method == 'DELETE' and 'DELETE' in allowed_methods:
                return self.ng_delete(request, *args, **kwargs)
        except self.model.DoesNotExist as e:
            return self.error_json_response(e.args[0], 404)
        except NgMissingParameterError as e:
            return self.error_json_response(e.args[0])
        except JSONResponseException as e:
            return self.error_json_response(e.args[0], e.status_code)
        except ValidationError as e:
            if hasattr(e, 'error_dict'):
                return self.error_json_response('Form not valid', detail=e.message_dict)
            else:
                return self.error_json_response(e.message)

        return self.error_json_response('This view can not handle method {0}'.format(request.method), 405)
853272
def dispatch(self, request, *args, **kwargs):
        
        if self.requires_login:
            if settings.LOGIN_URL is None or settings.LOGOUT_URL is None:
                raise ImproperlyConfigured(
                    "LOGIN_URL and LOGOUT_URL "
                    "has to be defined if requires_login is True"
                )

            if not request.user.is_authenticated:
                return redirect(
                    "%s?next=%s"
                    % (
                        resolve_url(settings.LOGIN_URL),
                        quote(request.get_full_path()),
                    )
                )

        return super(View, self).dispatch(request, *args, **kwargs)
994196
def get_object(self):
        

        if not self.force_add and self.kwargs.get(self.slug_url_kwarg, None):
            return super(FormView, self).get_object()
        else:
            self.queryset = self.get_queryset()

        return None
787705
def requestTeams(self, team_names):
        
        if isinstance(team_names, six.string_types):
            raise TypeError('Teams should be passed as a list of '
                            'strings (not %r)' % (type(field_names),))

        for team_name in team_names:
            self.requestTeam(team_name)
549743
def login_required(func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url=None):
    
    def decorator(view_func):
        @functools.wraps(view_func, assigned=available_attrs(view_func))
        def _wrapped_view(request, *args, **kwargs):
            if is_authenticated(request.user):
                return view_func(request, *args, **kwargs)
            return handle_redirect_to_login(
                request,
                redirect_field_name=redirect_field_name,
                login_url=login_url
            )
        return _wrapped_view
    if func:
        return decorator(func)
    return decorator
1186493
function afterFindMatch(models){
		if(models.length != 1) return next(404);

		model = models[0];

		// Fetch Both Teams
		app.models.Team.findById(model.teamAId).exec(function(err, models){
			model.teamA = models.length ? models[0] : null;
			checkFetch();
		});

		app.models.Team.findById(model.teamBId).exec(function(err, models){
			model.teamB = models.length ? models[0] : null;
			checkFetch();
		});

		// Fetch Group
		app.models.Group.findById(model.groupId).exec(function(err, models){
			model.group = models.length ? models[0] : null;
			checkFetch();
		});
	}