Decorator for the View classes.
333653
def route(obj, rule, *args, **kwargs):
    """"""
    def decorator(cls):
        endpoint = kwargs.get('endpoint', camel_to_snake(cls.__name__))
        kwargs['view_func'] = cls.as_view(endpoint)
        obj.add_url_rule(rule, *args, **kwargs)
        return cls
    return decorator
91771
def decorate_function(self, name, decorator):
        
        self.functions[name] = decorator(self.functions[name])
698760
def get_view_response(self, request, page, view_func, view_args, view_kwargs):
        
        return view_func(request, page, *view_args, **view_kwargs)
327810
def process_view(self, request, view_func, view_args, view_kwargs):
        

        # Purge data in view method cache
        # Python 3's keys() method returns an iterator, so force evaluation before iterating.
        view_keys = list(VIEW_METHOD_DATA.keys())
        for key in view_keys:
            del VIEW_METHOD_DATA[key]

        self.view_data = {}

        try:
            cbv = view_func.view_class
        except AttributeError:
            cbv = False

        if cbv:

            self.view_data['cbv'] = True
            klass = view_func.view_class
            self.view_data['bases'] = [base.__name__ for base in inspect.getmro(klass)]
            # Inject with drugz

            for member in inspect.getmembers(view_func.view_class):
                # Check that we are interested in capturing data for this method
                # and ensure that a decorated method is not decorated multiple times.
                if member[0] in VIEW_METHOD_WHITEIST and member[0] not in PATCHED_METHODS[klass]:
                    decorate_method(klass, member[0])
                    PATCHED_METHODS[klass].append(member[0])
925735
def _apply_decorators(func, decorators):
    
    decorators = filter(_is_not_none_or_false, reversed(decorators))

    for decorator in decorators:
        func = decorator(func)

    return func
33560
private final View[] getNonDecorViews(View[] views) {
		View[] decorViews = null;

		if(views != null) {
			decorViews = new View[views.length];

			int i = 0;
			View view;

			for (int j = 0; j < views.length; j++) {
				view = views[j];
				if (!isDecorView(view)) {
					decorViews[i] = view;
					i++;
				}
			}
		}
		return decorViews;
	}
1284490
def supports(cls, *functionalities):
        
        def _decorator(view):
            """
            Internal decorator that updates the given view's list of supported
            functionalities.
            """
            # pylint: disable=protected-access
            if not hasattr(view, "_supports"):
                view._supports = set()
            for functionality in functionalities:
                view._supports.add(functionality)
            return view
        return _decorator
1320659
def decorator(target):
    """"""

    def decorate(fn):
        spec = inspect.getargspec(fn)
        names = tuple(spec[0]) + spec[1:3] + (fn.__name__,)
        targ_name, fn_name = unique_symbols(names, 'target', 'fn')

        metadata = dict(target=targ_name, fn=fn_name)
        metadata.update(format_argspec_plus(spec, grouped=False))

        code = 'lambda %(args)s: %(target)s(%(fn)s, %(apply_kw)s)' % (
                metadata)
        decorated = eval(code, {targ_name: target, fn_name: fn})
        decorated.__defaults__ = getattr(fn, 'im_func', fn).__defaults__
        return update_wrapper(decorated, fn)
    return update_wrapper(decorate, target)
1059081
def build_views(self):
        
        # Then loop through and run them all
        for view_str in self.view_list:
            logger.debug("Building %s" % view_str)
            if self.verbosity > 1:
                self.stdout.write("Building %s" % view_str)
            view = get_callable(view_str)
            self.get_view_instance(view).build_method()
18032
def __add_class_views(self):
        
        config = self.config
        if "class_views" in self.kwargs:
            class_views = self.kwargs.pop("class_views")

            for route, view in class_views:
                if issubclass(view, endpoints.BaseEndpoint) and isinstance(
                    route, str
                ):
                    self.bp.add_route(
                        view.as_view(
                            self.responses,
                            config=self.config,
                            instance=self.instance,
                        ),
                        route,
                        strict_slashes=config.strict_slashes(),
                    )
                else:
                    raise exceptions.InvalidClassViewsFormat()
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
389601
def as_view(cls, action_map=None, **initkwargs):
        

        # Needs to re-implement the method but contains all the things the parent does.
        if not action_map:  # actions must not be empty
            raise TypeError("action_map is a required argument.")

        def view(request):
            self = cls(**initkwargs)
            self.request = request
            self.lookup_url_kwargs = self.request.matchdict
            self.action_map = action_map
            self.action = self.action_map.get(self.request.method.lower())

            for method, action in action_map.items():
                handler = getattr(self, action)
                setattr(self, method, handler)

            return self.dispatch(self.request, **self.request.matchdict)

        return view
1047758
def register(self, backbone_view_class):
        
        if backbone_view_class not in self._registry:
            self._registry.append(backbone_view_class)
814772
def method_name(self):
        
        if isinstance(self.view_func, str):
            return self.view_func
        return self.view_func.__name__
505849
def register_view_for(cls, app, action, classview, attr):
        
        if 'view_for_endpoints' not in cls.__dict__:
            cls.view_for_endpoints = {}
        cls.view_for_endpoints.setdefault(app, {})[action] = (classview, attr)
362797
def middleware_class(api=None):
    """"""
    def decorator(middleware_class):
        apply_to_api = hug.API(api) if api else hug.api.from_object(middleware_class)
        apply_to_api.http.add_middleware(middleware_class())
        return middleware_class
    return decorator
1029114
def decorate(*reversed_views):
    
    fns = reversed_views[::-1]
    view = fns[0]
    for wrapper in fns[1:]:
        view = wrapper(view)
    return view