示例#1
0
    def after(self):
        if getattr(self.context, 'forms', None) is not None:
            self.context.forms.append(self)
            return

        config = Configurator.with_context(self.context)
        display_action = FormAction(None)
        for action in [display_action] + self._actions:
            form_view = FormView(self.controller, action, self._actions,
                                 self.form_id, self.method)

            config.add_view(permission=self.permission,
                            for_=self.for_,
                            view=form_view,
                            name=self.name,
                            request_param=action.name,
                            route_name=self.route_name,
                            containment=self.containment,
                            renderer=self.renderer,
                            wrapper=self.wrapper)
示例#2
0
    def after(self):
        if getattr(self.context, 'forms', None) is not None:
            self.context.forms.append(self)
            return
        
        config = Configurator.with_context(self.context)
        display_action = FormAction(None)
        for action in [display_action] + self._actions:
            form_view = FormView(self.controller, action, self._actions,
                                 self.form_id, self.method)

            config.add_view(permission=self.permission,
                            for_=self.for_,
                            view=form_view,
                            name=self.name,
                            request_param=action.name,
                            route_name=self.route_name,
                            containment=self.containment,
                            renderer=self.renderer,
                            wrapper=self.wrapper)
示例#3
0
    def after(self):
        config = Configurator.with_context(self.context)
        derived_view = config.derive_view(self.view)

        def forms_view(context, request):
            forms = []
            for formdef in self.forms:
                formid = formdef.form_id
                actions = formdef._actions
                controller = formdef.controller(context, request)
                form = form_from_controller(controller, formid, actions)
                form.controller = controller
                form.bfg_actions = actions
                forms.append((formid, form))

            request.forms = [x[1] for x in forms]
            request_formid = request.params.get('__formish_form__')

            for formid, form in forms:
                if formid == request_formid:
                    for action in form.bfg_actions:
                        if action.name in request.params:

                            def curried_view():
                                return derived_view(context, request)

                            return submitted(request, form, form.controller,
                                             action, curried_view)

            return derived_view(context, request)

        config.add_view(permission=self.permission,
                        for_=self.for_,
                        view=forms_view,
                        name=self.name,
                        route_name=self.route_name,
                        containment=self.containment,
                        renderer=self.renderer,
                        wrapper=self.wrapper)
示例#4
0
    def after(self):
        config = Configurator.with_context(self.context)
        derived_view = config.derive_view(self.view)

        def forms_view(context, request):
            forms = []
            for formdef in self.forms:
                formid = formdef.form_id
                actions = formdef._actions
                controller = formdef.controller(context, request)
                form = form_from_controller(controller, formid, actions)
                form.controller = controller
                form.bfg_actions = actions
                forms.append((formid, form))

            request.forms = [ x[1] for x in forms ]
            request_formid = request.params.get('__formish_form__')

            for formid, form in forms:
                if formid == request_formid:
                    for action in form.bfg_actions:
                        if action.name in request.params:
                            def curried_view():
                                return derived_view(context, request)
                            return submitted(request, form, form.controller,
                                             action, curried_view)

            return derived_view(context, request)

        config.add_view(
            permission=self.permission,
            for_=self.for_,
            view=forms_view,
            name=self.name,
            route_name=self.route_name,
            containment=self.containment,
            renderer=self.renderer,
            wrapper=self.wrapper)