def manually_handle_validation(self):
        # This is done to check that we don't break compatibility
        # with external modules that perform custom validation like tgext.socketio

        controller = self.__class__.validate_function
        args = (2, 'NaN')
        try:
            output = ''
            validate_params = get_params_with_argspec(controller, {}, args)
            params = DecoratedController._perform_validate(
                controller, validate_params)
        except validation_errors as inv:
            handler, output = DecoratedController._handle_validation_errors(
                controller, args, {}, inv, None)

        return output
Ejemplo n.º 2
0
    def manually_handle_validation(self):
        # This is done to check that we don't break compatibility
        # with external modules that perform custom validation like tgext.socketio

        controller = self.__class__.validate_function
        args = (2, 'NaN')
        try:
            output = ''
            validate_params = get_params_with_argspec(controller, {}, args)
            params = DecoratedController._perform_validate(controller,
                                                           validate_params)
        except validation_errors as inv:
            handler, output = DecoratedController._handle_validation_errors(controller,
                                                                            args, {},
                                                                            inv, None)

        return output
Ejemplo n.º 3
0
        def _perform_call(self, func, args):
            try:
                # If these are the __before__ or __after__ methods, they will have
                # no decoration property. This will make the default
                # DecoratedController._perform_call() method choke, so we'll handle
                # them the same way ObjectDispatchController handles them.
                func_name = func.__name__
                if func_name in ['__before__', '__after__']:
                    action_name = str(args.get('action', 'lookup'))
                    controller = getattr(self, action_name)
                    if hasattr(controller.im_class, func_name):
                        return getattr(controller.im_self, func_name)(*args)
                    return
                else:
                    controller = func
                    params = args
                    remainder = ''

                    # Remove all extraneous Routing related params.
                    # Otherwise, they'd be passed as kwargs to the rendered action.
                    undesirables = [
                        'pylons',
                        'start_response',
                        'environ',
                        'action',
                        'controller'
                    ]
                    for x in undesirables:
                        params.pop(x, None)

                    # Add the GET/POST request params to our params dict,
                    # overriding any defaults passed in.
                    params.update(pylons.request.params.mixed())

                    result = DecoratedController._perform_call(
                        self, controller, params, remainder=remainder)
            except HTTPException, httpe:
                result = httpe
                # 304 Not Modified's shouldn't have a content-type set
                if result.status_int == 304:
                    result.headers.pop('Content-Type', None)
                result._exception = True
Ejemplo n.º 4
0
Archivo: base.py Proyecto: TimmGit/posy
    def _perform_call(self, func, args):
        languages = []
        lang = tg.session.get('lang')
        if lang:
            languages.append(lang)
        setup_i18n(languages)

        routingArgs = None

        if isinstance(args, dict) and 'url' in args:
            routingArgs = args['url']

        try:
            controller, remainder, params = self._get_routing_info(routingArgs)
            result = DecoratedController._perform_call(
                self, controller, params, remainder=remainder)
        except HTTPException, httpe:
            result = httpe
            # 304 Not Modified's shouldn't have a content-type set
            if result.status_int == 304:
                result.headers.pop('Content-Type', None)
            result._exception = True
Ejemplo n.º 5
0
Archivo: base.py Proyecto: Turante/posy
    def _perform_call(self, func, args):
        languages = []
        lang = tg.session.get('lang')
        if lang:
            languages.append(lang)
        setup_i18n(languages)

        routingArgs = None

        if isinstance(args, dict) and 'url' in args:
            routingArgs = args['url']

        try:
            controller, remainder, params = self._get_routing_info(routingArgs)
            result = DecoratedController._perform_call(self,
                                                       controller,
                                                       params,
                                                       remainder=remainder)
        except HTTPException, httpe:
            result = httpe
            # 304 Not Modified's shouldn't have a content-type set
            if result.status_int == 304:
                result.headers.pop('Content-Type', None)
            result._exception = True